v0.5.2
This release fixes a critical issue with relation table DDL generation and ensures proper SurrealDB table type specifications are applied during schema creation.
🛠️ Fixes
Section titled “🛠️ Fixes”Schema Generation
Section titled “Schema Generation”-
Fixed table TYPE clause in DDL generation: Restored the missing
TYPEclause inDEFINE TABLEstatements. The DDL generator now correctly outputs:DEFINE TABLE tablename TYPE RELATIONfor relation tables created withTable.relation()DEFINE TABLE tablename TYPE NORMALfor normal tables created withTable.normal()
Previously, relation tables were being created as normal tables, which prevented proper SurrealDB edge/graph functionality.
// Now correctly generates TYPE RELATION DDLclass Likes extends Table.relation({name: 'likes',schemafull: true,fields: {in: Field.record(() => User),out: Field.record(() => Post),}}) {}// Generates: DEFINE TABLE likes TYPE RELATION SCHEMAFULL;
Relation Table Creation
Section titled “Relation Table Creation”-
Enhanced relation table record creation: Updated the
createmethod to use SurrealDB’sinsertRelationmethod specifically for relation tables, ensuring proper edge record creation and validation. -
Improved type safety: Replaced generic
any[]types with more specific{ [key: string]: unknown }[]for better type safety in relation table creation.
🧪 Tests
Section titled “🧪 Tests”- Updated all DDL generation tests to expect correct
TYPEclauses in generated schema - Added
OVERWRITEmethod to relation table schema applications to prevent conflicts during testing - Enhanced test coverage for relation table functionality