-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
figure out if type can be inferred for elements of IN #6222
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
Comments
I don't have a fix for this one right now, as the mechanics of IN are very different. if you give your column a type then it will know these are integers: stmt = (
select("*")
.select_from(table("demo", schema=None))
.where(column("id", Integer).in_([1, 2]))
.limit(2)
) |
Thanks for the quick response. In my case, I don't have independent information about the types of the columns, but I do have an extant engine. Could it be appropriate to use introspection as the mechanism for inferring types? |
people typically use Table reflection when they have an engine because that will give you a structure that creates the most appropriate SQL given the type information, sure. The whole "table()/column()" thing is more for testing and one-offs. |
Mike Bayer has proposed a fix for this issue in the master branch: Infer types in BindParameter when expanding=True https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/2726 |
the above patch fixes |
Thank you for the quick update! |
Describe the bug
When I compile a SqlAlchemy statement with an IN clause using 1.4, I am unable to compile an IN statement using
literal_binds
.Expected behavior
I believe that I should be able to compile to a valid text SQL statement using
literal_binds
; I have observed this (excellent!) description of new behavior described in the recent changelog:https://docs.sqlalchemy.org/en/14/changelog/migration_14.html#all-in-expressions-render-parameters-for-each-value-in-the-list-on-the-fly-e-g-expanding-parameters; however, it seems to explicitly suggest that this formulation should still work.
To Reproduce
Error
The text was updated successfully, but these errors were encountered: