Skip to content

CLI ignores per-entity table override; entity named Order generates table order (SQL reserved word) #98

Description

@cultron

Summary

The per-entity table override in .apsorc is silently ignored for at least some entity names: an entity named Order with "table": "order_record" still generates the table as order (snake_case of the entity name) — a SQL reserved word. The override IS honored for other compound-name entities in the same schema, so the failure appears name-specific.

Environment

  • @apso/cli 0.19.0
  • TypeScript / NestJS / TypeORM target

Repro

.apsorc entity:

{ "name": "Order", "table": "order_record", "primaryKeyType": "uuid", "fields": [ ... ] }

Run apso generate.

Expected

The generated entity maps to table order_record (the explicit override).

Actual

The generated entity maps to table order — the override is ignored and the name is snake_cased. order is a SQL reserved word; it only works because TypeORM quotes identifiers via the repository API. Any hand-written raw SQL that forgets to quote "order" breaks.

Impact

  • Silently ignoring an explicit table override is a correctness footgun.
  • Landing on a reserved word is a latent hazard for raw queries / migrations / external tooling.

Suggested fix

Honor the explicit per-entity table override; and/or detect reserved words and either auto-quote consistently in generated SQL or refuse with a clear error. A diagnostic when a derived table name is a reserved word would also help.

Workaround

Set table to match what's generated (order) and quote it in any raw SQL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions