Skip to content
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

Need a check that field order in schema.rs matches order in dbinit.sql #4570

Open
sunshowers opened this issue Nov 28, 2023 · 2 comments
Open

Comments

@sunshowers
Copy link
Contributor

sunshowers commented Nov 28, 2023

While developing #4520 I encountered a mysterious error Received more than 8 bytes decoding i64. Was an expression of a different type misidentified as BigInt? (full error). It took a bit of debugging work to figure out that this was happening due to a mismatch in the field order between dbinit.sql and schema.rs.

We should have a check to ensure that the field order (and maybe types, if possible) match.

Another related issue is checking that the order of fields in a Queryable or Insertable struct is the same as that in the database.

@sunshowers
Copy link
Contributor Author

sunshowers commented Nov 29, 2023

This was visible because in #4520 I attempted to use UpdateAndCheck, which uses * rather than listing out all the columns.

smklein added a commit that referenced this issue Nov 29, 2023
Related to #4570 , but
not a direct fix for it

This PR removes a usage of ".\*" from a SQL query. Using ".\*" in sql
queries is somewhat risky -- it makes an implicit dependency on order,
and can make backwards compatibility difficult in certain circumstances.

Instead, this PR provides a `ColumnWalker`, for converting a tuple of
columns to an iterator, and requests the expected columns explicitly.
@davepacheco
Copy link
Collaborator

Maybe something for #1534.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants