Skip to content

Python and Go generators ignore per-entity table override (parity with #98) #107

Closed

Description

@cultron

Summary

Follow-up to #98 (fixed for TypeScript in PR #106). The Python and Go generators derive the table name the same way the TS generator did — snakeCase(entity.name) — and never read the per-entity table override, so they have the same bug: an entity named Order with "table": "order_record" generates the reserved word order.

Evidence

  • src/lib/generators/python.ts sets snakeCasedName: snakeCase(name); templates/python/models/model.eta uses __tablename__ = "<%= it.snakeCasedName %>" (and the same value for FK/join-table/index names).
  • src/lib/generators/go.ts sets snakeCasedName: snakeCase(name); templates/go/models/model.eta returns "<%= it.snakeCasedName %>" as the table name.

Recommended fix

Mirror #106: add a tableName = entity.table || snakeCase(name) field and use it for the actual table name (__tablename__ / Go TableName()). Note both templates also interpolate snakeCasedName into FK references, join-table names, and index names — decide whether those should follow the overridden table name too (TypeORM sidesteps this because it derives FKs from entity classes, not string names). Add generator tests as in #106.

Auto-fix eligibility

Localized generator/template fix with tests; no publish/deploy side effect until merged (merge publishes @apso/cli). Same class as #98.

Activity

  1. cultron commented on Aug 1, 2026

    @cultron
    ContributorAuthor

    Fixed in PR #119 (base `main`). Ported the #106 pattern to both generators: they now surface `tableName = entity.table || snakeCase(name)`.

    • Go: `TableName()` returns the override.
    • Python: the override flows to `tablename` and the self-referencing ManyToMany `ForeignKey`, join-table name, join-column prefix, and index name — so every reference to this entity's own table stays consistent (needed in SQLAlchemy, where the join FK references the table by string name).

    Byte-identical output without an override. Override + fallback tests added to both suites; full suite 318/0. Cross-entity FKs to other tables left out of scope, matching #106. Merge = npm publish, so left for Matt.

    — apso-build, 2026-08-01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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