-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix #3579: Unexpected end of row when setup diesel #3713
Conversation
Okay I just found an issue in the implementation: The following yields different results between xinfo and info:
This is the diesel_cli/tests/print_schema/print_schema_generated_columns_generated_always testcase. |
Okay looking more into this.
@weiznich I'll defer to you to decide on the right approach. My personal opinion is that 2. is the worst solution, since it will generate incorrect schemas. 1. would be my preferred appraoch, given that 3.26 is over 5 years old at this point, but it depends on the guarantees you want to give users of diesel. If we go with 3. I can give it a shot, depending on time available on my end. Just let me know waht you think is best. |
Thanks for opening this PR and working on the underlying issue. We want to go with the second variant (using The manual impl of |
@weiznich Okay cool. In this case i think the PR is actually fine as is, i just need a way to fix the unit tests for the case of |
I think its fine for the unit test to assume that it is run with an sqlite version that supports generated columns. That means it will always use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. The fix looks good. I have some minor cleanup request that would be great to resolve, otherwise I approve that change.
We use `PRAGMA table_info` for older versions of sqlite. This returns fewer columns that `PRAGMA table_xinfo` which we use in newer versions of sqlite, making the two code paths incompatbile with the `Queryable` implementations. We instead now use `sql_query` with an implementation of `QueryableByName` to return default values for the case of `PRAGMA table_info`.
Good catch. In fact this made me realised that getting the primary key information also relied upon pragma_info_table being Now the pull requests consists of 3 steps (I prefer smaller, logically isolated changes):
Hope this is what you hoped for :). Thanks for the patience |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. It looks good now 👍
I've locally verified that it fixes the problem by manually setting the sqlite version in the corresponding function to 3.20 (which uses the pragma table_info()
path.)
Fix diesel-rs#3579: Unexpected end of row when setup diesel
We use
PRAGMA table_info
for older versions of sqlite. This returns fewer columns thatPRAGMA table_xinfo
which we use in newer versions of sqlite, making the two code paths incompatbile with theQueryable
implementations. We instead now usesql_query
with an implementation ofQueryableByName
to return default values for the case ofPRAGMA table_info
.Note this is a WIP implementation. It's my first contribution and dive into the diesel codebase so there is a good chance this is not the right way to do it.
Questions
derive
instead of a manual implementation ofQueryableByName
?Tests
cargo test --features sqlite --no-default-features
successfully.Unexpected end of row
when setupdiesel
#3579 .NOT TESTED!
I have not tested the case of an older sqlite version as described in #3579 as I currently do
not have a setup for this. I will refer to the author of the issue to test this branch for me.