-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support SQLite foreign key short hand syntax #101
Comments
After trying to pinpoint the issue I've taken notice in this line where after inserting
and running the code we see
becomes a
I think tbl_fk.ref_col may contain a DynIden with an empty formatting in its Debug implementation (might be intended behaviour though?). I say this since from what I saw it doesn't make sense for an empty tbl_fk.ref_col to result into a non-empty vector. If someone wants to continue looking into it feel free. |
Thank you for your investigation @wnmrmr |
Seems like
so the |
I just encountered this myself. When the error occurred only after creating a table with a single column FK, my initial hunch proved correct. This DDL code will create a table and provoke the "Ident is not allowed to be empty" error, it was initially generated by my IDE, IntelliJ IDEA: CREATE TABLE app_config (
cfg_app TEXT NOT NULL
CONSTRAINT app_config_apps_app_name_fk
REFERENCES apps
ON UPDATE CASCADE ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
cfg_name TEXT NOT NULL,
cfg_content TEXT NOT NULL,
CONSTRAINT app_config_app_name_pk
PRIMARY KEY (cfg_app, cfg_name)
); This DDL will create an identical table but will not provoke the error, I modified it after another table with a compound FK: CREATE TABLE app_config (
cfg_app TEXT NOT NULL,
cfg_name TEXT NOT NULL,
cfg_content TEXT NOT NULL,
CONSTRAINT app_config_app_name_pk
PRIMARY KEY (cfg_app, cfg_name),
CONSTRAINT app_config_apps_app_name_fk
FOREIGN KEY (cfg_app) REFERENCES apps(app_name)
ON UPDATE CASCADE ON DELETE RESTRICT
DEFERRABLE INITIALLY DEFERRED
); |
Thank you everyone REFERENCES apps # wont work
REFERENCES apps(app_name) # works So I can confirm that the culprit is the shorthand syntax of SQLite https://www.sqlite.org/foreignkeys.html Section 3
This behaviour is not supported yet in sea-schema, so please specify the target column explicitly for now. The ideal fix would be to handle this specifically in SQLite's schema discovery and probe the table's primary key when the |
I use command
sea-orm-cli generate entity -o entity/src/ --with-serde -t host_site
Adapter is SQLite
My host_site table DDL:
And I have error:
thread 'main' panicked at 'Ident is not allowed to be empty; use Option', /Users/averichev/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.36/src/fallback.rs:686:9
note: run with
RUST_BACKTRACE=1
environment variable to display a backtraceNeed help, please
The text was updated successfully, but these errors were encountered: