Skip to content

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.

  • Fixed table TYPE clause in DDL generation: Restored the missing TYPE clause in DEFINE TABLE statements. The DDL generator now correctly outputs:

    • DEFINE TABLE tablename TYPE RELATION for relation tables created with Table.relation()
    • DEFINE TABLE tablename TYPE NORMAL for normal tables created with Table.normal()

    Previously, relation tables were being created as normal tables, which prevented proper SurrealDB edge/graph functionality.

    // Now correctly generates TYPE RELATION DDL
    class Likes extends Table.relation({
    name: 'likes',
    schemafull: true,
    fields: {
    in: Field.record(() => User),
    out: Field.record(() => Post),
    }
    }) {}
    // Generates: DEFINE TABLE likes TYPE RELATION SCHEMAFULL;
  • Enhanced relation table record creation: Updated the create method to use SurrealDB’s insertRelation 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.

  • 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