diff --git a/bindings/dart/lib/src/database.dart b/bindings/dart/lib/src/database.dart index 56d64c1..b47f9cd 100644 --- a/bindings/dart/lib/src/database.dart +++ b/bindings/dart/lib/src/database.dart @@ -868,19 +868,19 @@ class Database { } /// Returns the structure and data type of an attribute. - ({String structure, String dataType}) getAttributeType(String collection, String attribute) { + ({String dataStructure, String dataType}) getAttributeType(String collection, String attribute) { _ensureNotClosed(); final arena = Arena(); try { - final outStructure = arena(); + final outDataStructure = arena(); final outDataType = arena(); final err = bindings.psr_database_get_attribute_type( _ptr, collection.toNativeUtf8(allocator: arena).cast(), attribute.toNativeUtf8(allocator: arena).cast(), - outStructure, + outDataStructure, outDataType, ); @@ -888,7 +888,7 @@ class Database { throw DatabaseException.fromError(err, "Failed to get attribute type for '$collection.$attribute'"); } - final structure = switch (outStructure.value) { + final dataStructure = switch (outDataStructure.value) { 0 => 'scalar', 1 => 'vector', 2 => 'set', @@ -902,7 +902,7 @@ class Database { _ => 'unknown', }; - return (structure: structure, dataType: dataType); + return (dataStructure: dataStructure, dataType: dataType); } finally { arena.releaseAll(); } diff --git a/bindings/dart/lib/src/ffi/bindings.dart b/bindings/dart/lib/src/ffi/bindings.dart index 75d81b0..4dd3de3 100644 --- a/bindings/dart/lib/src/ffi/bindings.dart +++ b/bindings/dart/lib/src/ffi/bindings.dart @@ -174,6 +174,45 @@ class PsrDatabaseBindings { late final _psr_database_create_element = _psr_database_create_elementPtr .asFunction, ffi.Pointer, ffi.Pointer)>(); + int psr_database_update_element( + ffi.Pointer db, + ffi.Pointer collection, + int id, + ffi.Pointer element, + ) { + return _psr_database_update_element( + db, + collection, + id, + element, + ); + } + + late final _psr_database_update_elementPtr = _lookup< + ffi.NativeFunction< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer, ffi.Int64, + ffi.Pointer)>>('psr_database_update_element'); + late final _psr_database_update_element = _psr_database_update_elementPtr + .asFunction, ffi.Pointer, int, ffi.Pointer)>(); + + int psr_database_delete_element_by_id( + ffi.Pointer db, + ffi.Pointer collection, + int id, + ) { + return _psr_database_delete_element_by_id( + db, + collection, + id, + ); + } + + late final _psr_database_delete_element_by_idPtr = + _lookup, ffi.Pointer, ffi.Int64)>>( + 'psr_database_delete_element_by_id'); + late final _psr_database_delete_element_by_id = _psr_database_delete_element_by_idPtr + .asFunction, ffi.Pointer, int)>(); + int psr_database_set_scalar_relation( ffi.Pointer db, ffi.Pointer collection, @@ -788,14 +827,14 @@ class PsrDatabaseBindings { ffi.Pointer db, ffi.Pointer collection, ffi.Pointer attribute, - ffi.Pointer out_structure, + ffi.Pointer out_data_structure, ffi.Pointer out_data_type, ) { return _psr_database_get_attribute_type( db, collection, attribute, - out_structure, + out_data_structure, out_data_type, ); } @@ -1034,45 +1073,6 @@ class PsrDatabaseBindings { int Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, int, ffi.Pointer>, int)>(); - int psr_database_delete_element_by_id( - ffi.Pointer db, - ffi.Pointer collection, - int id, - ) { - return _psr_database_delete_element_by_id( - db, - collection, - id, - ); - } - - late final _psr_database_delete_element_by_idPtr = - _lookup, ffi.Pointer, ffi.Int64)>>( - 'psr_database_delete_element_by_id'); - late final _psr_database_delete_element_by_id = _psr_database_delete_element_by_idPtr - .asFunction, ffi.Pointer, int)>(); - - int psr_database_update_element( - ffi.Pointer db, - ffi.Pointer collection, - int id, - ffi.Pointer element, - ) { - return _psr_database_update_element( - db, - collection, - id, - element, - ); - } - - late final _psr_database_update_elementPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Pointer, ffi.Int64, - ffi.Pointer)>>('psr_database_update_element'); - late final _psr_database_update_element = _psr_database_update_elementPtr - .asFunction, ffi.Pointer, int, ffi.Pointer)>(); - void psr_free_int_array( ffi.Pointer values, ) { @@ -1486,18 +1486,6 @@ abstract class psr_log_level_t { static const int PSR_LOG_OFF = 4; } -abstract class psr_attribute_structure_t { - static const int PSR_ATTRIBUTE_SCALAR = 0; - static const int PSR_ATTRIBUTE_VECTOR = 1; - static const int PSR_ATTRIBUTE_SET = 2; -} - -abstract class psr_data_type_t { - static const int PSR_DATA_TYPE_INTEGER = 0; - static const int PSR_DATA_TYPE_REAL = 1; - static const int PSR_DATA_TYPE_TEXT = 2; -} - final class psr_database_options_t extends ffi.Struct { @ffi.Int() external int read_only; @@ -1506,6 +1494,18 @@ final class psr_database_options_t extends ffi.Struct { external int console_level; } +abstract class psr_data_structure_t { + static const int PSR_DATA_STRUCTURE_SCALAR = 0; + static const int PSR_DATA_STRUCTURE_VECTOR = 1; + static const int PSR_DATA_STRUCTURE_SET = 2; +} + +abstract class psr_data_type_t { + static const int PSR_DATA_TYPE_INTEGER = 0; + static const int PSR_DATA_TYPE_REAL = 1; + static const int PSR_DATA_TYPE_TEXT = 2; +} + final class psr_database extends ffi.Opaque {} typedef psr_database_t = psr_database; diff --git a/bindings/dart/test/read_test.dart b/bindings/dart/test/read_test.dart index c00317c..8ce6d93 100644 --- a/bindings/dart/test/read_test.dart +++ b/bindings/dart/test/read_test.dart @@ -622,7 +622,7 @@ void main() { ); try { final result = db.getAttributeType('Configuration', 'integer_attribute'); - expect(result.structure, equals('scalar')); + expect(result.dataStructure, equals('scalar')); expect(result.dataType, equals('integer')); } finally { db.close(); @@ -636,7 +636,7 @@ void main() { ); try { final result = db.getAttributeType('Configuration', 'float_attribute'); - expect(result.structure, equals('scalar')); + expect(result.dataStructure, equals('scalar')); expect(result.dataType, equals('real')); } finally { db.close(); @@ -650,7 +650,7 @@ void main() { ); try { final result = db.getAttributeType('Configuration', 'string_attribute'); - expect(result.structure, equals('scalar')); + expect(result.dataStructure, equals('scalar')); expect(result.dataType, equals('text')); } finally { db.close(); @@ -664,7 +664,7 @@ void main() { ); try { final result = db.getAttributeType('Collection', 'value_int'); - expect(result.structure, equals('vector')); + expect(result.dataStructure, equals('vector')); expect(result.dataType, equals('integer')); } finally { db.close(); @@ -678,7 +678,7 @@ void main() { ); try { final result = db.getAttributeType('Collection', 'value_float'); - expect(result.structure, equals('vector')); + expect(result.dataStructure, equals('vector')); expect(result.dataType, equals('real')); } finally { db.close(); @@ -692,7 +692,7 @@ void main() { ); try { final result = db.getAttributeType('Collection', 'tag'); - expect(result.structure, equals('set')); + expect(result.dataStructure, equals('set')); expect(result.dataType, equals('text')); } finally { db.close(); diff --git a/bindings/julia/src/PSRDatabase.jl b/bindings/julia/src/PSRDatabase.jl index 51d406d..e468d24 100644 --- a/bindings/julia/src/PSRDatabase.jl +++ b/bindings/julia/src/PSRDatabase.jl @@ -10,13 +10,13 @@ include("lua_runner.jl") export Element, Database, LuaRunner, DatabaseException export get_attribute_type -export PSR_ATTRIBUTE_SCALAR, PSR_ATTRIBUTE_VECTOR, PSR_ATTRIBUTE_SET +export PSR_DATA_STRUCTURE_SCALAR, PSR_DATA_STRUCTURE_VECTOR, PSR_DATA_STRUCTURE_SET export PSR_DATA_TYPE_INTEGER, PSR_DATA_TYPE_REAL, PSR_DATA_TYPE_TEXT # Re-export enums from C module -const PSR_ATTRIBUTE_SCALAR = C.PSR_ATTRIBUTE_SCALAR -const PSR_ATTRIBUTE_VECTOR = C.PSR_ATTRIBUTE_VECTOR -const PSR_ATTRIBUTE_SET = C.PSR_ATTRIBUTE_SET +const PSR_DATA_STRUCTURE_SCALAR = C.PSR_DATA_STRUCTURE_SCALAR +const PSR_DATA_STRUCTURE_VECTOR = C.PSR_DATA_STRUCTURE_VECTOR +const PSR_DATA_STRUCTURE_SET = C.PSR_DATA_STRUCTURE_SET const PSR_DATA_TYPE_INTEGER = C.PSR_DATA_TYPE_INTEGER const PSR_DATA_TYPE_REAL = C.PSR_DATA_TYPE_REAL const PSR_DATA_TYPE_TEXT = C.PSR_DATA_TYPE_TEXT diff --git a/bindings/julia/src/c_api.jl b/bindings/julia/src/c_api.jl index ffd7582..e403c7f 100644 --- a/bindings/julia/src/c_api.jl +++ b/bindings/julia/src/c_api.jl @@ -37,18 +37,6 @@ const libpsr_database_c = joinpath(@__DIR__, "..", "..", "..", "build", library_ PSR_ERROR_NOT_FOUND = -6 end -@cenum psr_attribute_structure_t::Int32 begin - PSR_ATTRIBUTE_SCALAR = 0 - PSR_ATTRIBUTE_VECTOR = 1 - PSR_ATTRIBUTE_SET = 2 -end - -@cenum psr_data_type_t::Int32 begin - PSR_DATA_TYPE_INTEGER = 0 - PSR_DATA_TYPE_REAL = 1 - PSR_DATA_TYPE_TEXT = 2 -end - function psr_error_string(error) @ccall libpsr_database_c.psr_error_string(error::psr_error_t)::Ptr{Cchar} end @@ -70,6 +58,18 @@ struct psr_database_options_t console_level::psr_log_level_t end +@cenum psr_data_structure_t::UInt32 begin + PSR_DATA_STRUCTURE_SCALAR = 0 + PSR_DATA_STRUCTURE_VECTOR = 1 + PSR_DATA_STRUCTURE_SET = 2 +end + +@cenum psr_data_type_t::UInt32 begin + PSR_DATA_TYPE_INTEGER = 0 + PSR_DATA_TYPE_REAL = 1 + PSR_DATA_TYPE_TEXT = 2 +end + function psr_database_options_default() @ccall libpsr_database_c.psr_database_options_default()::psr_database_options_t end @@ -114,6 +114,14 @@ function psr_database_create_element(db, collection, element) @ccall libpsr_database_c.psr_database_create_element(db::Ptr{psr_database_t}, collection::Ptr{Cchar}, element::Ptr{psr_element_t})::Int64 end +function psr_database_update_element(db, collection, id, element) + @ccall libpsr_database_c.psr_database_update_element(db::Ptr{psr_database_t}, collection::Ptr{Cchar}, id::Int64, element::Ptr{psr_element_t})::psr_error_t +end + +function psr_database_delete_element_by_id(db, collection, id) + @ccall libpsr_database_c.psr_database_delete_element_by_id(db::Ptr{psr_database_t}, collection::Ptr{Cchar}, id::Int64)::psr_error_t +end + function psr_database_set_scalar_relation(db, collection, attribute, from_label, to_label) @ccall libpsr_database_c.psr_database_set_scalar_relation(db::Ptr{psr_database_t}, collection::Ptr{Cchar}, attribute::Ptr{Cchar}, from_label::Ptr{Cchar}, to_label::Ptr{Cchar})::psr_error_t end @@ -198,8 +206,8 @@ function psr_database_read_element_ids(db, collection, out_ids, out_count) @ccall libpsr_database_c.psr_database_read_element_ids(db::Ptr{psr_database_t}, collection::Ptr{Cchar}, out_ids::Ptr{Ptr{Int64}}, out_count::Ptr{Csize_t})::psr_error_t end -function psr_database_get_attribute_type(db, collection, attribute, out_structure, out_data_type) - @ccall libpsr_database_c.psr_database_get_attribute_type(db::Ptr{psr_database_t}, collection::Ptr{Cchar}, attribute::Ptr{Cchar}, out_structure::Ptr{psr_attribute_structure_t}, out_data_type::Ptr{psr_data_type_t})::psr_error_t +function psr_database_get_attribute_type(db, collection, attribute, out_data_structure, out_data_type) + @ccall libpsr_database_c.psr_database_get_attribute_type(db::Ptr{psr_database_t}, collection::Ptr{Cchar}, attribute::Ptr{Cchar}, out_data_structure::Ptr{psr_data_structure_t}, out_data_type::Ptr{psr_data_type_t})::psr_error_t end function psr_database_update_scalar_integer(db, collection, attribute, id, value) @@ -238,14 +246,6 @@ function psr_database_update_set_strings(db, collection, attribute, id, values, @ccall libpsr_database_c.psr_database_update_set_strings(db::Ptr{psr_database_t}, collection::Ptr{Cchar}, attribute::Ptr{Cchar}, id::Int64, values::Ptr{Ptr{Cchar}}, count::Csize_t)::psr_error_t end -function psr_database_delete_element_by_id(db, collection, id) - @ccall libpsr_database_c.psr_database_delete_element_by_id(db::Ptr{psr_database_t}, collection::Ptr{Cchar}, id::Int64)::psr_error_t -end - -function psr_database_update_element(db, collection, id, element) - @ccall libpsr_database_c.psr_database_update_element(db::Ptr{psr_database_t}, collection::Ptr{Cchar}, id::Int64, element::Ptr{psr_element_t})::psr_error_t -end - function psr_free_int_array(values) @ccall libpsr_database_c.psr_free_int_array(values::Ptr{Int64})::Cvoid end diff --git a/bindings/julia/src/database.jl b/bindings/julia/src/database.jl index 0d0594b..08fea7a 100644 --- a/bindings/julia/src/database.jl +++ b/bindings/julia/src/database.jl @@ -510,15 +510,15 @@ function read_element_ids(db::Database, collection::String) end function get_attribute_type(db::Database, collection::String, attribute::String) - out_structure = Ref{C.psr_attribute_structure_t}(C.PSR_ATTRIBUTE_SCALAR) + out_data_structure = Ref{C.psr_data_structure_t}(C.PSR_DATA_STRUCTURE_SCALAR) out_data_type = Ref{C.psr_data_type_t}(C.PSR_DATA_TYPE_INTEGER) - err = C.psr_database_get_attribute_type(db.ptr, collection, attribute, out_structure, out_data_type) + err = C.psr_database_get_attribute_type(db.ptr, collection, attribute, out_data_structure, out_data_type) if err != C.PSR_OK throw(DatabaseException("Failed to get attribute type for '$collection.$attribute'")) end - return (structure = out_structure[], data_type = out_data_type[]) + return (data_structure = out_data_structure[], data_type = out_data_type[]) end function delete_element_by_id!(db::Database, collection::String, id::Int64) diff --git a/bindings/julia/test/test_read.jl b/bindings/julia/test/test_read.jl index fe92174..a437fcb 100644 --- a/bindings/julia/test/test_read.jl +++ b/bindings/julia/test/test_read.jl @@ -361,7 +361,7 @@ end db = PSRDatabase.from_schema(":memory:", path_schema) result = PSRDatabase.get_attribute_type(db, "Configuration", "integer_attribute") - @test result.structure == PSRDatabase.PSR_ATTRIBUTE_SCALAR + @test result.data_structure == PSRDatabase.PSR_DATA_STRUCTURE_SCALAR @test result.data_type == PSRDatabase.PSR_DATA_TYPE_INTEGER PSRDatabase.close!(db) @@ -372,7 +372,7 @@ end db = PSRDatabase.from_schema(":memory:", path_schema) result = PSRDatabase.get_attribute_type(db, "Configuration", "float_attribute") - @test result.structure == PSRDatabase.PSR_ATTRIBUTE_SCALAR + @test result.data_structure == PSRDatabase.PSR_DATA_STRUCTURE_SCALAR @test result.data_type == PSRDatabase.PSR_DATA_TYPE_REAL PSRDatabase.close!(db) @@ -383,7 +383,7 @@ end db = PSRDatabase.from_schema(":memory:", path_schema) result = PSRDatabase.get_attribute_type(db, "Configuration", "string_attribute") - @test result.structure == PSRDatabase.PSR_ATTRIBUTE_SCALAR + @test result.data_structure == PSRDatabase.PSR_DATA_STRUCTURE_SCALAR @test result.data_type == PSRDatabase.PSR_DATA_TYPE_TEXT PSRDatabase.close!(db) @@ -394,7 +394,7 @@ end db = PSRDatabase.from_schema(":memory:", path_schema) result = PSRDatabase.get_attribute_type(db, "Collection", "value_int") - @test result.structure == PSRDatabase.PSR_ATTRIBUTE_VECTOR + @test result.data_structure == PSRDatabase.PSR_DATA_STRUCTURE_VECTOR @test result.data_type == PSRDatabase.PSR_DATA_TYPE_INTEGER PSRDatabase.close!(db) @@ -405,7 +405,7 @@ end db = PSRDatabase.from_schema(":memory:", path_schema) result = PSRDatabase.get_attribute_type(db, "Collection", "value_float") - @test result.structure == PSRDatabase.PSR_ATTRIBUTE_VECTOR + @test result.data_structure == PSRDatabase.PSR_DATA_STRUCTURE_VECTOR @test result.data_type == PSRDatabase.PSR_DATA_TYPE_REAL PSRDatabase.close!(db) @@ -416,7 +416,7 @@ end db = PSRDatabase.from_schema(":memory:", path_schema) result = PSRDatabase.get_attribute_type(db, "Collection", "tag") - @test result.structure == PSRDatabase.PSR_ATTRIBUTE_SET + @test result.data_structure == PSRDatabase.PSR_DATA_STRUCTURE_SET @test result.data_type == PSRDatabase.PSR_DATA_TYPE_TEXT PSRDatabase.close!(db) diff --git a/include/psr/attribute_type.h b/include/psr/attribute_type.h index 96372d3..f9486c1 100644 --- a/include/psr/attribute_type.h +++ b/include/psr/attribute_type.h @@ -1,16 +1,16 @@ #ifndef PSR_ATTRIBUTE_TYPE_H #define PSR_ATTRIBUTE_TYPE_H +#include "data_type.h" #include "export.h" namespace psr { -enum class AttributeStructure { Scalar, Vector, Set }; -enum class AttributeDataType { Integer, Real, Text }; +enum class DataStructure { Scalar, Vector, Set }; struct PSR_API AttributeType { - AttributeStructure structure; - AttributeDataType data_type; + DataStructure data_structure; + DataType data_type; }; } // namespace psr diff --git a/include/psr/c/database.h b/include/psr/c/database.h index b5b8848..c9a4ed8 100644 --- a/include/psr/c/database.h +++ b/include/psr/c/database.h @@ -22,8 +22,12 @@ typedef struct { psr_log_level_t console_level; } psr_database_options_t; -// Attribute structure types -typedef enum { PSR_ATTRIBUTE_SCALAR = 0, PSR_ATTRIBUTE_VECTOR = 1, PSR_ATTRIBUTE_SET = 2 } psr_attribute_structure_t; +// Attribute data structure +typedef enum { + PSR_DATA_STRUCTURE_SCALAR = 0, + PSR_DATA_STRUCTURE_VECTOR = 1, + PSR_DATA_STRUCTURE_SET = 2 +} psr_data_structure_t; // Attribute data types typedef enum { PSR_DATA_TYPE_INTEGER = 0, PSR_DATA_TYPE_REAL = 1, PSR_DATA_TYPE_TEXT = 2 } psr_data_type_t; @@ -208,7 +212,7 @@ PSR_C_API psr_error_t psr_database_read_element_ids(psr_database_t* db, PSR_C_API psr_error_t psr_database_get_attribute_type(psr_database_t* db, const char* collection, const char* attribute, - psr_attribute_structure_t* out_structure, + psr_data_structure_t* out_data_structure, psr_data_type_t* out_data_type); // Update scalar attributes (by element ID) diff --git a/include/psr/column_type.h b/include/psr/column_type.h deleted file mode 100644 index 8c7fa00..0000000 --- a/include/psr/column_type.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef PSR_COLUMN_TYPE_H -#define PSR_COLUMN_TYPE_H - -#include -#include - -namespace psr { - -enum class ColumnType { Integer, Real, Text }; - -inline ColumnType column_type_from_string(const std::string& type_str) { - if (type_str == "INTEGER") - return ColumnType::Integer; - else if (type_str == "REAL") - return ColumnType::Real; - else if (type_str == "TEXT") - return ColumnType::Text; - throw std::runtime_error("Unknown column type: " + type_str); -} - -inline const char* column_type_to_string(ColumnType type) { - switch (type) { - case ColumnType::Integer: - return "INTEGER"; - case ColumnType::Real: - return "REAL"; - case ColumnType::Text: - return "TEXT"; - } - return "UNKNOWN"; -} - -} // namespace psr - -#endif // PSR_COLUMN_TYPE_H diff --git a/include/psr/data_type.h b/include/psr/data_type.h new file mode 100644 index 0000000..693dd7c --- /dev/null +++ b/include/psr/data_type.h @@ -0,0 +1,35 @@ +#ifndef PSR_DATA_TYPE_H +#define PSR_DATA_TYPE_H + +#include +#include + +namespace psr { + +enum class DataType { Integer, Real, Text }; + +inline DataType data_type_from_string(const std::string& type_str) { + if (type_str == "INTEGER") + return DataType::Integer; + else if (type_str == "REAL") + return DataType::Real; + else if (type_str == "TEXT") + return DataType::Text; + throw std::runtime_error("Unknown data type: " + type_str); +} + +inline const char* data_type_to_string(DataType type) { + switch (type) { + case DataType::Integer: + return "INTEGER"; + case DataType::Real: + return "REAL"; + case DataType::Text: + return "TEXT"; + } + return "UNKNOWN"; +} + +} // namespace psr + +#endif // PSR_DATA_TYPE_H diff --git a/include/psr/schema.h b/include/psr/schema.h index 046343a..4c89cfd 100644 --- a/include/psr/schema.h +++ b/include/psr/schema.h @@ -1,7 +1,7 @@ #ifndef PSR_SCHEMA_H #define PSR_SCHEMA_H -#include "column_type.h" +#include "data_type.h" #include "export.h" #include @@ -15,7 +15,7 @@ namespace psr { struct ColumnDefinition { std::string name; - ColumnType type; + DataType type; bool not_null; bool primary_key; }; @@ -40,7 +40,7 @@ struct TableDefinition { std::vector foreign_keys; std::vector indexes; - std::optional get_column_type(const std::string& column) const; + std::optional get_data_type(const std::string& column) const; bool has_column(const std::string& column) const; const ColumnDefinition* get_column(const std::string& column) const; }; @@ -55,7 +55,7 @@ class PSR_API Schema { bool has_table(const std::string& name) const; // Column type lookup (throws if table/column not found) - ColumnType get_column_type(const std::string& table, const std::string& column) const; + DataType get_data_type(const std::string& table, const std::string& column) const; // Vector/Set table naming convention static std::string vector_table_name(const std::string& collection, const std::string& group); diff --git a/include/psr/type_validator.h b/include/psr/type_validator.h index b19b53c..96d0ccb 100644 --- a/include/psr/type_validator.h +++ b/include/psr/type_validator.h @@ -1,7 +1,7 @@ #ifndef PSR_TYPE_VALIDATOR_H #define PSR_TYPE_VALIDATOR_H -#include "column_type.h" +#include "data_type.h" #include "export.h" #include "schema.h" #include "value.h" @@ -23,7 +23,7 @@ class PSR_API TypeValidator { void validate_array(const std::string& table, const std::string& column, const std::vector& values) const; // Low-level: validate value against explicit type - static void validate_value(const std::string& context, ColumnType expected_type, const Value& value); + static void validate_value(const std::string& context, DataType expected_type, const Value& value); private: const Schema& schema_; diff --git a/src/c_api_database.cpp b/src/c_api_database.cpp index 1bfe783..f16ec0f 100644 --- a/src/c_api_database.cpp +++ b/src/c_api_database.cpp @@ -884,34 +884,34 @@ PSR_C_API psr_error_t psr_database_update_set_strings(psr_database_t* db, PSR_C_API psr_error_t psr_database_get_attribute_type(psr_database_t* db, const char* collection, const char* attribute, - psr_attribute_structure_t* out_structure, + psr_data_structure_t* out_data_structure, psr_data_type_t* out_data_type) { - if (!db || !collection || !attribute || !out_structure || !out_data_type) { + if (!db || !collection || !attribute || !out_data_structure || !out_data_type) { return PSR_ERROR_INVALID_ARGUMENT; } try { auto attr_type = db->db.get_attribute_type(collection, attribute); - switch (attr_type.structure) { - case psr::AttributeStructure::Scalar: - *out_structure = PSR_ATTRIBUTE_SCALAR; + switch (attr_type.data_structure) { + case psr::DataStructure::Scalar: + *out_data_structure = PSR_DATA_STRUCTURE_SCALAR; break; - case psr::AttributeStructure::Vector: - *out_structure = PSR_ATTRIBUTE_VECTOR; + case psr::DataStructure::Vector: + *out_data_structure = PSR_DATA_STRUCTURE_VECTOR; break; - case psr::AttributeStructure::Set: - *out_structure = PSR_ATTRIBUTE_SET; + case psr::DataStructure::Set: + *out_data_structure = PSR_DATA_STRUCTURE_SET; break; } switch (attr_type.data_type) { - case psr::AttributeDataType::Integer: + case psr::DataType::Integer: *out_data_type = PSR_DATA_TYPE_INTEGER; break; - case psr::AttributeDataType::Real: + case psr::DataType::Real: *out_data_type = PSR_DATA_TYPE_REAL; break; - case psr::AttributeDataType::Text: + case psr::DataType::Text: *out_data_type = PSR_DATA_TYPE_TEXT; break; } diff --git a/src/database.cpp b/src/database.cpp index 72401bf..db7e1ca 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -1376,25 +1376,11 @@ AttributeType Database::get_attribute_type(const std::string& collection, const throw std::runtime_error("Collection not found in schema: " + collection); } - // Helper to convert ColumnType to AttributeDataType - auto to_data_type = [](ColumnType ct) -> AttributeDataType { - switch (ct) { - case ColumnType::Integer: - return AttributeDataType::Integer; - case ColumnType::Real: - return AttributeDataType::Real; - case ColumnType::Text: - return AttributeDataType::Text; - default: - throw std::runtime_error("Unknown column type"); - } - }; - // Check if attribute exists as scalar (column on collection table) if (table_def->has_column(attribute)) { - auto col_type = table_def->get_column_type(attribute); - if (col_type) { - return AttributeType{AttributeStructure::Scalar, to_data_type(*col_type)}; + auto data_type = table_def->get_data_type(attribute); + if (data_type) { + return AttributeType{DataStructure::Scalar, *data_type}; } } @@ -1407,9 +1393,9 @@ AttributeType Database::get_attribute_type(const std::string& collection, const const auto* vec_table = impl_->schema->get_table(table_name); if (vec_table && vec_table->has_column(attribute)) { - auto col_type = vec_table->get_column_type(attribute); - if (col_type) { - return AttributeType{AttributeStructure::Vector, to_data_type(*col_type)}; + auto data_type = vec_table->get_data_type(attribute); + if (data_type) { + return AttributeType{DataStructure::Vector, *data_type}; } } } @@ -1423,9 +1409,9 @@ AttributeType Database::get_attribute_type(const std::string& collection, const const auto* set_table = impl_->schema->get_table(table_name); if (set_table && set_table->has_column(attribute)) { - auto col_type = set_table->get_column_type(attribute); - if (col_type) { - return AttributeType{AttributeStructure::Set, to_data_type(*col_type)}; + auto data_type = set_table->get_data_type(attribute); + if (data_type) { + return AttributeType{DataStructure::Set, *data_type}; } } } diff --git a/src/schema.cpp b/src/schema.cpp index 617e021..7411d68 100644 --- a/src/schema.cpp +++ b/src/schema.cpp @@ -7,7 +7,7 @@ namespace psr { // TableDefinition methods -std::optional TableDefinition::get_column_type(const std::string& column) const { +std::optional TableDefinition::get_data_type(const std::string& column) const { auto it = columns.find(column); if (it != columns.end()) { return it->second.type; @@ -49,12 +49,12 @@ bool Schema::has_table(const std::string& name) const { return tables_.find(name) != tables_.end(); } -ColumnType Schema::get_column_type(const std::string& table, const std::string& column) const { +DataType Schema::get_data_type(const std::string& table, const std::string& column) const { const auto* tbl = get_table(table); if (!tbl) { throw std::runtime_error("Table not found in schema: " + table); } - auto type = tbl->get_column_type(column); + auto type = tbl->get_data_type(column); if (!type) { throw std::runtime_error("Column '" + column + "' not found in table '" + table + "'"); } @@ -214,7 +214,7 @@ std::vector Schema::query_columns(sqlite3* db, const std::stri col.name = name ? name : ""; std::string type_str = type ? type : ""; - col.type = column_type_from_string(type_str); + col.type = data_type_from_string(type_str); col.not_null = sqlite3_column_int(stmt, 3) != 0; col.primary_key = sqlite3_column_int(stmt, 5) != 0; diff --git a/src/schema_validator.cpp b/src/schema_validator.cpp index 0407635..91c0860 100644 --- a/src/schema_validator.cpp +++ b/src/schema_validator.cpp @@ -67,25 +67,25 @@ void SchemaValidator::validate_collection(const std::string& name) { } // Must have 'id' column as primary key - const auto* id_col = table->get_column("id"); - if (!id_col || !id_col->primary_key) { + const auto* id_column = table->get_column("id"); + if (!id_column || !id_column->primary_key) { validation_error("Collection '" + name + "' must have 'id' as primary key"); } // Must have 'label' column with TEXT type and NOT NULL constraint - const auto* label_col = table->get_column("label"); - if (!label_col) { + const auto* label_column = table->get_column("label"); + if (!label_column) { validation_error("Collection '" + name + "' must have a 'label' column"); } - if (label_col->type != ColumnType::Text) { + if (label_column->type != DataType::Text) { validation_error("Collection '" + name + "' label column must be TEXT type"); } - if (!label_col->not_null) { + if (!label_column->not_null) { validation_error("Collection '" + name + "' label column must have NOT NULL constraint"); } // Check for UNIQUE constraint on label - bool label_unique = false; + auto label_unique = false; for (const auto& idx : table->indexes) { if (idx.unique && idx.columns.size() == 1 && idx.columns[0] == "label") { label_unique = true; @@ -104,7 +104,7 @@ void SchemaValidator::validate_vector_table(const std::string& name) { } // Get parent collection - std::string parent = schema_.get_parent_collection(name); + auto parent = schema_.get_parent_collection(name); if (std::find(collections_.begin(), collections_.end(), parent) == collections_.end()) { validation_error("Vector table '" + name + "' references non-existent collection '" + parent + "'"); } diff --git a/src/type_validator.cpp b/src/type_validator.cpp index 8cb4091..8c03933 100644 --- a/src/type_validator.cpp +++ b/src/type_validator.cpp @@ -7,20 +7,20 @@ namespace psr { TypeValidator::TypeValidator(const Schema& schema) : schema_(schema) {} void TypeValidator::validate_scalar(const std::string& table, const std::string& column, const Value& value) const { - ColumnType expected = schema_.get_column_type(table, column); + auto expected = schema_.get_data_type(table, column); validate_value("column '" + column + "'", expected, value); } void TypeValidator::validate_array(const std::string& table, const std::string& column, const std::vector& values) const { - ColumnType expected = schema_.get_column_type(table, column); + auto expected = schema_.get_data_type(table, column); for (size_t i = 0; i < values.size(); ++i) { validate_value("array '" + column + "' index " + std::to_string(i), expected, values[i]); } } -void TypeValidator::validate_value(const std::string& context, ColumnType expected_type, const Value& value) { +void TypeValidator::validate_value(const std::string& context, DataType expected_type, const Value& value) { std::visit( [&](auto&& arg) { using T = std::decay_t; @@ -29,21 +29,21 @@ void TypeValidator::validate_value(const std::string& context, ColumnType expect // NULL allowed for any type return; } else if constexpr (std::is_same_v) { - if (expected_type != ColumnType::Integer) { + if (expected_type != DataType::Integer) { throw std::runtime_error("Type mismatch for " + context + ": expected " + - column_type_to_string(expected_type) + ", got INTEGER"); + data_type_to_string(expected_type) + ", got INTEGER"); } } else if constexpr (std::is_same_v) { // REAL can be stored in INTEGER or REAL columns - if (expected_type != ColumnType::Real && expected_type != ColumnType::Integer) { + if (expected_type != DataType::Real && expected_type != DataType::Integer) { throw std::runtime_error("Type mismatch for " + context + ": expected " + - column_type_to_string(expected_type) + ", got REAL"); + data_type_to_string(expected_type) + ", got REAL"); } } else if constexpr (std::is_same_v) { // String can go to TEXT or INTEGER (FK label resolution happens elsewhere) - if (expected_type != ColumnType::Text && expected_type != ColumnType::Integer) { + if (expected_type != DataType::Text && expected_type != DataType::Integer) { throw std::runtime_error("Type mismatch for " + context + ": expected " + - column_type_to_string(expected_type) + ", got TEXT"); + data_type_to_string(expected_type) + ", got TEXT"); } } }, diff --git a/tests/test_c_api_database_read.cpp b/tests/test_c_api_database_read.cpp index 30aabed..ba0d7a2 100644 --- a/tests/test_c_api_database_read.cpp +++ b/tests/test_c_api_database_read.cpp @@ -809,12 +809,12 @@ TEST(DatabaseCApi, GetAttributeTypeScalarInteger) { auto db = psr_database_from_schema(":memory:", VALID_SCHEMA("basic.sql").c_str(), &options); ASSERT_NE(db, nullptr); - psr_attribute_structure_t structure; + psr_data_structure_t data_structure; psr_data_type_t data_type; - auto err = psr_database_get_attribute_type(db, "Configuration", "integer_attribute", &structure, &data_type); + auto err = psr_database_get_attribute_type(db, "Configuration", "integer_attribute", &data_structure, &data_type); EXPECT_EQ(err, PSR_OK); - EXPECT_EQ(structure, PSR_ATTRIBUTE_SCALAR); + EXPECT_EQ(data_structure, PSR_DATA_STRUCTURE_SCALAR); EXPECT_EQ(data_type, PSR_DATA_TYPE_INTEGER); psr_database_close(db); @@ -826,12 +826,12 @@ TEST(DatabaseCApi, GetAttributeTypeScalarReal) { auto db = psr_database_from_schema(":memory:", VALID_SCHEMA("basic.sql").c_str(), &options); ASSERT_NE(db, nullptr); - psr_attribute_structure_t structure; + psr_data_structure_t data_structure; psr_data_type_t data_type; - auto err = psr_database_get_attribute_type(db, "Configuration", "float_attribute", &structure, &data_type); + auto err = psr_database_get_attribute_type(db, "Configuration", "float_attribute", &data_structure, &data_type); EXPECT_EQ(err, PSR_OK); - EXPECT_EQ(structure, PSR_ATTRIBUTE_SCALAR); + EXPECT_EQ(data_structure, PSR_DATA_STRUCTURE_SCALAR); EXPECT_EQ(data_type, PSR_DATA_TYPE_REAL); psr_database_close(db); @@ -843,12 +843,12 @@ TEST(DatabaseCApi, GetAttributeTypeScalarText) { auto db = psr_database_from_schema(":memory:", VALID_SCHEMA("basic.sql").c_str(), &options); ASSERT_NE(db, nullptr); - psr_attribute_structure_t structure; + psr_data_structure_t data_structure; psr_data_type_t data_type; - auto err = psr_database_get_attribute_type(db, "Configuration", "string_attribute", &structure, &data_type); + auto err = psr_database_get_attribute_type(db, "Configuration", "string_attribute", &data_structure, &data_type); EXPECT_EQ(err, PSR_OK); - EXPECT_EQ(structure, PSR_ATTRIBUTE_SCALAR); + EXPECT_EQ(data_structure, PSR_DATA_STRUCTURE_SCALAR); EXPECT_EQ(data_type, PSR_DATA_TYPE_TEXT); psr_database_close(db); @@ -860,12 +860,12 @@ TEST(DatabaseCApi, GetAttributeTypeVectorInteger) { auto db = psr_database_from_schema(":memory:", VALID_SCHEMA("collections.sql").c_str(), &options); ASSERT_NE(db, nullptr); - psr_attribute_structure_t structure; + psr_data_structure_t data_structure; psr_data_type_t data_type; - auto err = psr_database_get_attribute_type(db, "Collection", "value_int", &structure, &data_type); + auto err = psr_database_get_attribute_type(db, "Collection", "value_int", &data_structure, &data_type); EXPECT_EQ(err, PSR_OK); - EXPECT_EQ(structure, PSR_ATTRIBUTE_VECTOR); + EXPECT_EQ(data_structure, PSR_DATA_STRUCTURE_VECTOR); EXPECT_EQ(data_type, PSR_DATA_TYPE_INTEGER); psr_database_close(db); @@ -877,12 +877,12 @@ TEST(DatabaseCApi, GetAttributeTypeVectorReal) { auto db = psr_database_from_schema(":memory:", VALID_SCHEMA("collections.sql").c_str(), &options); ASSERT_NE(db, nullptr); - psr_attribute_structure_t structure; + psr_data_structure_t data_structure; psr_data_type_t data_type; - auto err = psr_database_get_attribute_type(db, "Collection", "value_float", &structure, &data_type); + auto err = psr_database_get_attribute_type(db, "Collection", "value_float", &data_structure, &data_type); EXPECT_EQ(err, PSR_OK); - EXPECT_EQ(structure, PSR_ATTRIBUTE_VECTOR); + EXPECT_EQ(data_structure, PSR_DATA_STRUCTURE_VECTOR); EXPECT_EQ(data_type, PSR_DATA_TYPE_REAL); psr_database_close(db); @@ -894,12 +894,12 @@ TEST(DatabaseCApi, GetAttributeTypeSetText) { auto db = psr_database_from_schema(":memory:", VALID_SCHEMA("collections.sql").c_str(), &options); ASSERT_NE(db, nullptr); - psr_attribute_structure_t structure; + psr_data_structure_t data_structure; psr_data_type_t data_type; - auto err = psr_database_get_attribute_type(db, "Collection", "tag", &structure, &data_type); + auto err = psr_database_get_attribute_type(db, "Collection", "tag", &data_structure, &data_type); EXPECT_EQ(err, PSR_OK); - EXPECT_EQ(structure, PSR_ATTRIBUTE_SET); + EXPECT_EQ(data_structure, PSR_DATA_STRUCTURE_SET); EXPECT_EQ(data_type, PSR_DATA_TYPE_TEXT); psr_database_close(db); @@ -911,9 +911,9 @@ TEST(DatabaseCApi, GetAttributeTypeNotFound) { auto db = psr_database_from_schema(":memory:", VALID_SCHEMA("basic.sql").c_str(), &options); ASSERT_NE(db, nullptr); - psr_attribute_structure_t structure; + psr_data_structure_t data_structure; psr_data_type_t data_type; - auto err = psr_database_get_attribute_type(db, "Configuration", "nonexistent", &structure, &data_type); + auto err = psr_database_get_attribute_type(db, "Configuration", "nonexistent", &data_structure, &data_type); EXPECT_EQ(err, PSR_ERROR_DATABASE); @@ -926,27 +926,27 @@ TEST(DatabaseCApi, GetAttributeTypeInvalidArgument) { auto db = psr_database_from_schema(":memory:", VALID_SCHEMA("basic.sql").c_str(), &options); ASSERT_NE(db, nullptr); - psr_attribute_structure_t structure; + psr_data_structure_t data_structure; psr_data_type_t data_type; // Null db - auto err = psr_database_get_attribute_type(nullptr, "Configuration", "label", &structure, &data_type); + auto err = psr_database_get_attribute_type(nullptr, "Configuration", "label", &data_structure, &data_type); EXPECT_EQ(err, PSR_ERROR_INVALID_ARGUMENT); // Null collection - err = psr_database_get_attribute_type(db, nullptr, "label", &structure, &data_type); + err = psr_database_get_attribute_type(db, nullptr, "label", &data_structure, &data_type); EXPECT_EQ(err, PSR_ERROR_INVALID_ARGUMENT); // Null attribute - err = psr_database_get_attribute_type(db, "Configuration", nullptr, &structure, &data_type); + err = psr_database_get_attribute_type(db, "Configuration", nullptr, &data_structure, &data_type); EXPECT_EQ(err, PSR_ERROR_INVALID_ARGUMENT); - // Null out_structure + // Null out_data_structure err = psr_database_get_attribute_type(db, "Configuration", "label", nullptr, &data_type); EXPECT_EQ(err, PSR_ERROR_INVALID_ARGUMENT); // Null out_data_type - err = psr_database_get_attribute_type(db, "Configuration", "label", &structure, nullptr); + err = psr_database_get_attribute_type(db, "Configuration", "label", &data_structure, nullptr); EXPECT_EQ(err, PSR_ERROR_INVALID_ARGUMENT); psr_database_close(db); diff --git a/tests/test_database_read.cpp b/tests/test_database_read.cpp index 6799c4a..d84b4e1 100644 --- a/tests/test_database_read.cpp +++ b/tests/test_database_read.cpp @@ -478,24 +478,24 @@ TEST(Database, GetAttributeTypeScalarInteger) { auto db = psr::Database::from_schema(":memory:", VALID_SCHEMA("basic.sql"), {.console_level = psr::LogLevel::off}); auto attr_type = db.get_attribute_type("Configuration", "integer_attribute"); - EXPECT_EQ(attr_type.structure, psr::AttributeStructure::Scalar); - EXPECT_EQ(attr_type.data_type, psr::AttributeDataType::Integer); + EXPECT_EQ(attr_type.data_structure, psr::DataStructure::Scalar); + EXPECT_EQ(attr_type.data_type, psr::DataType::Integer); } TEST(Database, GetAttributeTypeScalarReal) { auto db = psr::Database::from_schema(":memory:", VALID_SCHEMA("basic.sql"), {.console_level = psr::LogLevel::off}); auto attr_type = db.get_attribute_type("Configuration", "float_attribute"); - EXPECT_EQ(attr_type.structure, psr::AttributeStructure::Scalar); - EXPECT_EQ(attr_type.data_type, psr::AttributeDataType::Real); + EXPECT_EQ(attr_type.data_structure, psr::DataStructure::Scalar); + EXPECT_EQ(attr_type.data_type, psr::DataType::Real); } TEST(Database, GetAttributeTypeScalarText) { auto db = psr::Database::from_schema(":memory:", VALID_SCHEMA("basic.sql"), {.console_level = psr::LogLevel::off}); auto attr_type = db.get_attribute_type("Configuration", "string_attribute"); - EXPECT_EQ(attr_type.structure, psr::AttributeStructure::Scalar); - EXPECT_EQ(attr_type.data_type, psr::AttributeDataType::Text); + EXPECT_EQ(attr_type.data_structure, psr::DataStructure::Scalar); + EXPECT_EQ(attr_type.data_type, psr::DataType::Text); } TEST(Database, GetAttributeTypeVectorInteger) { @@ -503,8 +503,8 @@ TEST(Database, GetAttributeTypeVectorInteger) { psr::Database::from_schema(":memory:", VALID_SCHEMA("collections.sql"), {.console_level = psr::LogLevel::off}); auto attr_type = db.get_attribute_type("Collection", "value_int"); - EXPECT_EQ(attr_type.structure, psr::AttributeStructure::Vector); - EXPECT_EQ(attr_type.data_type, psr::AttributeDataType::Integer); + EXPECT_EQ(attr_type.data_structure, psr::DataStructure::Vector); + EXPECT_EQ(attr_type.data_type, psr::DataType::Integer); } TEST(Database, GetAttributeTypeVectorReal) { @@ -512,8 +512,8 @@ TEST(Database, GetAttributeTypeVectorReal) { psr::Database::from_schema(":memory:", VALID_SCHEMA("collections.sql"), {.console_level = psr::LogLevel::off}); auto attr_type = db.get_attribute_type("Collection", "value_float"); - EXPECT_EQ(attr_type.structure, psr::AttributeStructure::Vector); - EXPECT_EQ(attr_type.data_type, psr::AttributeDataType::Real); + EXPECT_EQ(attr_type.data_structure, psr::DataStructure::Vector); + EXPECT_EQ(attr_type.data_type, psr::DataType::Real); } TEST(Database, GetAttributeTypeSetText) { @@ -521,8 +521,8 @@ TEST(Database, GetAttributeTypeSetText) { psr::Database::from_schema(":memory:", VALID_SCHEMA("collections.sql"), {.console_level = psr::LogLevel::off}); auto attr_type = db.get_attribute_type("Collection", "tag"); - EXPECT_EQ(attr_type.structure, psr::AttributeStructure::Set); - EXPECT_EQ(attr_type.data_type, psr::AttributeDataType::Text); + EXPECT_EQ(attr_type.data_structure, psr::DataStructure::Set); + EXPECT_EQ(attr_type.data_type, psr::DataType::Text); } TEST(Database, GetAttributeTypeNotFound) { diff --git a/tests/test_schema_validator.cpp b/tests/test_schema_validator.cpp index 61a4ef9..5d02dcf 100644 --- a/tests/test_schema_validator.cpp +++ b/tests/test_schema_validator.cpp @@ -125,8 +125,8 @@ TEST_F(SchemaValidatorFixture, GetAttributeTypeScalarInteger) { auto type = db.get_attribute_type("Configuration", "integer_attribute"); - EXPECT_EQ(type.structure, psr::AttributeStructure::Scalar); - EXPECT_EQ(type.data_type, psr::AttributeDataType::Integer); + EXPECT_EQ(type.data_structure, psr::DataStructure::Scalar); + EXPECT_EQ(type.data_type, psr::DataType::Integer); } TEST_F(SchemaValidatorFixture, GetAttributeTypeScalarReal) { @@ -134,8 +134,8 @@ TEST_F(SchemaValidatorFixture, GetAttributeTypeScalarReal) { auto type = db.get_attribute_type("Configuration", "float_attribute"); - EXPECT_EQ(type.structure, psr::AttributeStructure::Scalar); - EXPECT_EQ(type.data_type, psr::AttributeDataType::Real); + EXPECT_EQ(type.data_structure, psr::DataStructure::Scalar); + EXPECT_EQ(type.data_type, psr::DataType::Real); } TEST_F(SchemaValidatorFixture, GetAttributeTypeScalarText) { @@ -143,8 +143,8 @@ TEST_F(SchemaValidatorFixture, GetAttributeTypeScalarText) { auto type = db.get_attribute_type("Configuration", "label"); - EXPECT_EQ(type.structure, psr::AttributeStructure::Scalar); - EXPECT_EQ(type.data_type, psr::AttributeDataType::Text); + EXPECT_EQ(type.data_structure, psr::DataStructure::Scalar); + EXPECT_EQ(type.data_type, psr::DataType::Text); } TEST_F(SchemaValidatorFixture, GetAttributeTypeVectorInteger) { @@ -152,8 +152,8 @@ TEST_F(SchemaValidatorFixture, GetAttributeTypeVectorInteger) { auto type = db.get_attribute_type("Collection", "value_int"); - EXPECT_EQ(type.structure, psr::AttributeStructure::Vector); - EXPECT_EQ(type.data_type, psr::AttributeDataType::Integer); + EXPECT_EQ(type.data_structure, psr::DataStructure::Vector); + EXPECT_EQ(type.data_type, psr::DataType::Integer); } TEST_F(SchemaValidatorFixture, GetAttributeTypeSetText) { @@ -161,8 +161,8 @@ TEST_F(SchemaValidatorFixture, GetAttributeTypeSetText) { auto type = db.get_attribute_type("Collection", "tag"); - EXPECT_EQ(type.structure, psr::AttributeStructure::Set); - EXPECT_EQ(type.data_type, psr::AttributeDataType::Text); + EXPECT_EQ(type.data_structure, psr::DataStructure::Set); + EXPECT_EQ(type.data_type, psr::DataType::Text); } // ============================================================================ @@ -174,8 +174,8 @@ TEST_F(SchemaValidatorFixture, GetAttributeTypeVectorReal) { auto type = db.get_attribute_type("Collection", "value_float"); - EXPECT_EQ(type.structure, psr::AttributeStructure::Vector); - EXPECT_EQ(type.data_type, psr::AttributeDataType::Real); + EXPECT_EQ(type.data_structure, psr::DataStructure::Vector); + EXPECT_EQ(type.data_type, psr::DataType::Real); } TEST_F(SchemaValidatorFixture, GetAttributeTypeForeignKeyAsInteger) { @@ -184,8 +184,8 @@ TEST_F(SchemaValidatorFixture, GetAttributeTypeForeignKeyAsInteger) { // parent_id is a foreign key but stored as INTEGER auto type = db.get_attribute_type("Child", "parent_id"); - EXPECT_EQ(type.structure, psr::AttributeStructure::Scalar); - EXPECT_EQ(type.data_type, psr::AttributeDataType::Integer); + EXPECT_EQ(type.data_structure, psr::DataStructure::Scalar); + EXPECT_EQ(type.data_type, psr::DataType::Integer); } TEST_F(SchemaValidatorFixture, GetAttributeTypeSelfReference) { @@ -194,8 +194,8 @@ TEST_F(SchemaValidatorFixture, GetAttributeTypeSelfReference) { // sibling_id is a self-referencing foreign key auto type = db.get_attribute_type("Child", "sibling_id"); - EXPECT_EQ(type.structure, psr::AttributeStructure::Scalar); - EXPECT_EQ(type.data_type, psr::AttributeDataType::Integer); + EXPECT_EQ(type.data_structure, psr::DataStructure::Scalar); + EXPECT_EQ(type.data_type, psr::DataType::Integer); } // ============================================================================ @@ -226,7 +226,7 @@ TEST_F(SchemaValidatorFixture, RelationsSchemaWithVectorFK) { // Verify the schema loaded successfully with vector FK table auto type = db.get_attribute_type("Child", "label"); - EXPECT_EQ(type.data_type, psr::AttributeDataType::Text); + EXPECT_EQ(type.data_type, psr::DataType::Text); } // ============================================================================ @@ -294,6 +294,6 @@ TEST_F(SchemaValidatorFixture, GetAttributeTypeIdColumn) { // 'id' column should exist and be INTEGER auto type = db.get_attribute_type("Configuration", "id"); - EXPECT_EQ(type.structure, psr::AttributeStructure::Scalar); - EXPECT_EQ(type.data_type, psr::AttributeDataType::Integer); + EXPECT_EQ(type.data_structure, psr::DataStructure::Scalar); + EXPECT_EQ(type.data_type, psr::DataType::Integer); }