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

Create a wrapper around sqlacodegen to assist developers #15

Open
isedwards opened this issue Aug 12, 2021 · 0 comments
Open

Create a wrapper around sqlacodegen to assist developers #15

isedwards opened this issue Aug 12, 2021 · 0 comments

Comments

@isedwards
Copy link
Contributor

isedwards commented Aug 12, 2021

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

@isedwards isedwards self-assigned this Aug 12, 2021
@isedwards isedwards changed the title sqlacodegen doesn't not generate indexes correctly Create a wrapper around sqlacodegen to assist developers Aug 12, 2021
@isedwards isedwards removed their assignment Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant