You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In fact, I found that there are some problems in the code generated by sqlacodegen for sqlmodel, which is manifested in the introduction of redundant class CHAR and the mapped_column does not been import. The following is a detailed description of the problem:
(1) When encountering CHAR(36) and CHAR(36, 'utf8mb4_general_ci'), sqlacodegen will repeatedly import from different sources
from sqlalchemy import CHAR
from sqlalchemy.dialects.mysql import CHAR
The adjustment I made was to focus on sorted and high-priority imports, and to make a warn about duplicate imports.
for example:
WARN: Duplicate imports `{'CHAR'}` are detected from the package `sqlalchemy.dialects.mysql` and will be filtered,
which may cause abnormal behavior.
In fact, "from sqlalchemy import CHAR" supports general projects of multiple databases, while "from sqlalchemy.dialects.mysql import CHAR" is specifically for MySQL projects. If you project requires cross-database compatibility or you are not sure about the target database type, it is safer to use "sqlalchemy.CHAR".
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
In fact, I found that there are some problems in the code generated by
sqlacodegenforsqlmodel, which is manifested in the introduction of redundant classCHARand themapped_columndoes not been import. The following is a detailed description of the problem:(1) When encountering
CHAR(36)andCHAR(36, 'utf8mb4_general_ci'),sqlacodegenwill repeatedly import from different sourcesThe adjustment I made was to focus on sorted and high-priority imports, and to make a warn about duplicate imports.
for example:
In fact, "from sqlalchemy import CHAR" supports general projects of multiple databases, while "from sqlalchemy.dialects.mysql import CHAR" is specifically for MySQL projects. If you project requires cross-database compatibility or you are not sure about the target database type, it is safer to use "sqlalchemy.CHAR".
(2)
sqlmodeldoes not supportmapped_columnin the latest release(https://github.com/fastapi/sqlmodel/releases/tag/0.0.22), although someone has proposed a PR (fastapi/sqlmodel#1143), soColumnshould be used for the generation of sqlmodels for the time beingAll reactions