-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Assigning boolean in Select statement throws invalid cast. #2246
Comments
Problem here is that we are sending the following query to the database:
This then gets stored in the value buffer as {string, int, int}, rather than {string, int, bool} - hence the conversion fails, when we try to cast from int to bool. Possible solution is to evaluate the constant on the client, rather than sending it to server. We need to make sure that we still translate constants that are bound to the source query somehow (part of a more complex expression involving a column, or an argument to a function) |
Wouldn't |
It would, and would be a simpler solution. However the other solution seems to be consistent with our funcletization strategy (funcletize as much as we can if its deterministic and doesn't bring more rows from the database). |
Yes, better to do client eval here as it means less data on the wire. |
Agreed, but any idea of how much work it would take each way? We need to be careful not to turn this little thing into something big 😄 |
Well, it shouldn't be too bad as we can already do the client eval. I will follow up with @maumar later today for an update. |
I think we got a very easy/local fix for this |
Problem is that a row projection containing a constant bool gets translated into integer (0 or 1) since 1 and 0 are the literal bit values for true and false. When we try to materialize, we try to cast integer 0 or 1 into bool, which causes an error. Fix is to not send standalone constants to the store, but instead deal with them on the client. This is consistent with our approach to functions (funcletize as much as we can)
Problem is that a row projection containing a constant bool gets translated into integer (0 or 1) since 1 and 0 are the literal bit values for true and false. When we try to materialize, we try to cast integer 0 or 1 into bool, which causes an error. Fix is to not send standalone constants to the store, but instead deal with them on the client. This is consistent with our approach to functions (funcletize as much as we can)
Fixed in e8e50c0 |
I have a DbContext like this:
This code throws an invalid cast
Works fine without 'Selected = true'.
Stack trace:
The text was updated successfully, but these errors were encountered: