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

`infer_schema!` blows up on tables with primary keys other than `id` #211

Closed
sgrif opened this Issue Feb 13, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@sgrif
Member

sgrif commented Feb 13, 2016

Not only that, but the error message gives absolutely nothing useful.

<diesel macros>:22:19: 16:16 error: use of undeclared type name `columns::id` [E0412]
(internal compiler error: unprintable span)
<diesel macros>:15:1: 17:58 note: in this expansion of table_body! (defined in <diesel macros>)
<diesel macros>:5:1: 6:2 note: in this expansion of table! (defined in <diesel macros>)
<diesel macros>:2:1: 2:64 note: in this expansion of table! (defined in <diesel macros>)
src/schema.rs:2:1: 2:40 note: in this expansion of table! (defined in <diesel macros>)

We can't fully solve this without adding composite primary key support, but we should try to handle singular primary keys other than id, and either skip tables with composite primary keys or at least give a more useful warning/error.

weiznich added a commit to weiznich/diesel that referenced this issue Apr 1, 2016

Fix diesel-rs#211: Allow other primary keys than id for infer_schema
* Implement detection of primary keys
* Print an error if there is a composite primary key
* If there is only one primary key, use this one

weiznich added a commit to weiznich/diesel that referenced this issue Apr 2, 2016

Fix diesel-rs#211: Allow other primary keys than id for infer_schema
* Implement detection of primary keys
* Print an error if there is a composite primary key
* If there is only one primary key, use this one

weiznich added a commit to weiznich/diesel that referenced this issue Apr 3, 2016

Fix diesel-rs#211: Allow other primary keys than id for infer_schema
* Implement detection of primary keys
* Print an error if there is a composite primary key
* If there is only one primary key, use this one

@sgrif sgrif closed this in 7377bb8 Apr 12, 2016

sgrif added a commit that referenced this issue Apr 12, 2016

Merge pull request #252 from weiznich/fix_211
Fix #211: Allow other primary keys than id for infer_schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment