Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Create a wrapper around sqlacodegen to assist developers #15

Open
@isedwards

Description

@isedwards

We are aware that sqlacodegen does not generate perfect models in the following circumstances:

  1. Primary keys are not present for tables
  2. Views are represented as simple tables
  3. Named indexes are not generated correctly
  4. Issues with plurals

Currently some of these issues are being fixed manually. Ideally we would provide a tool that reports the issues above and the manual work required - or we could go further and automate the fixes for some of these issues.

For 2&3 see comment opencdms-dev/pyopencdms#9 (comment) onwards.

Issues with plurals

ORM classes ending with letter “s” are not generated properly, sqlacodegen uses inflect. See https://stackoverflow.com/a/58010758 and the link to the issue in the inflect library
jaraco/inflect#15 (comment)

Examples from CliDE models:

class StationStatu(Base):
    __tablename__ = "station_status"
    __table_args__ = {"comment": "Stores allowed values for stations.status_id"}

class StationTimezone(Base):
    __tablename__ = "station_timezones"
    __table_args__ = {"comment": "Stores time zone that stations can be in."}

https://github.com/opencdms/pyopencdms/blob/8940ebfd5b3ee7dff5a2bde3b2a305361ff2ee37/opencdms/models/clide.py#L1538-L1554

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