未正确生成以字母 "s" 结尾的 ORM 类
ORM classes ending with letter "s" are not generated properly
我正在使用 SQLAlchemy 和 sqlacodegen 为我的 PostgreSQL 模型生成 ORM classes。但令我惊讶的是,以字母 "s" 结尾的 table 引起了问题。
比如我有一个table如下
employee_status
为此 table 生成的 ORM class 如下
Class EmployeeStatu(Base):
__tablename__ = "employee_status"
col1 = Column(String(32))
为什么 table 名称中存在 class 名称中的结尾字母 "s"?
sqlacodegen doesn't do this itself:
Model class naming logic
The table name (which is assumed to be in English) is converted to singular form using the "inflect" library. Then, every underscore is removed while transforming the next letter to upper case. For example, sales_invoices
becomes SalesInvoice
.
这似乎有 already been reported as a bug in that library。与此同时,没有什么可以阻止您手动更正 class 名称。
我正在使用 SQLAlchemy 和 sqlacodegen 为我的 PostgreSQL 模型生成 ORM classes。但令我惊讶的是,以字母 "s" 结尾的 table 引起了问题。
比如我有一个table如下
employee_status
为此 table 生成的 ORM class 如下
Class EmployeeStatu(Base):
__tablename__ = "employee_status"
col1 = Column(String(32))
为什么 table 名称中存在 class 名称中的结尾字母 "s"?
sqlacodegen doesn't do this itself:
Model class naming logic
The table name (which is assumed to be in English) is converted to singular form using the "inflect" library. Then, every underscore is removed while transforming the next letter to upper case. For example,
sales_invoices
becomesSalesInvoice
.
这似乎有 already been reported as a bug in that library。与此同时,没有什么可以阻止您手动更正 class 名称。