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
TYPE
clause inDEFINE TABLE
statements. The DDL generator now correctly outputs:DEFINE TABLE tablename TYPE RELATION
for relation tables created withTable.relation()
DEFINE TABLE tablename TYPE NORMAL
for 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
create
method to use SurrealDB’sinsertRelation
method 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
TYPE
clauses in generated schema - Added
OVERWRITE
method to relation table schema applications to prevent conflicts during testing - Enhanced test coverage for relation table functionality