-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Allow usage of Values as a column element in postgres #6289
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
this probalby needs a new coercions role that is similar to IN impl. Also any_() all_() should accept any SELECT statement just like in_() does. Adding a method like .scalar() to the Values construct, with a datatype that's |
Actually also the if we want to use the same construct, and I'm not sure we should, I think Then I guess we can decide if in and any/all should coerce using this |
any_() / all_() should coerce to this .scalar() thing because that's what in_() does right now as well: https://github.com/sqlalchemy/sqlalchemy/blob/master/lib/sqlalchemy/sql/coercions.py#L555 |
ok, but it does not really work that coercion in this case. I've corrected the sql above, but it renders this sql SELECT bar
FROM t, (VALUES (:param_1), (:param_2), (:param_3))
WHERE bar IN (SELECT bar
FROM (VALUES (:param_4), (:param_5), (:param_6))) |
we need a new coercion role to Do The Right Thing on this one. |
I think I get the gist, I'll try giving a go after the two other regressions.
|
yeah somehtiugn like. this one seemed like it didnt have any clear way to do it right now so if we get something up we can tweak it |
I'm not sure this can be generalized. -- 1
SELECT bar
FROM t
WHERE bar IN (SELECT anon_2 FROM (VALUES (1), (2), (42)) as anon_1(anon_2));
SELECT bar
FROM t
WHERE bar = ANY(SELECT anon_2 FROM (VALUES (1), (2), (42)) as anon_1(anon_2)) -- or s/ANY/ALL/ this instead complain that it needs cast -- 2
SELECT bar
FROM t
WHERE bar IN (SELECT anon_1 FROM (VALUES (1), (2), (42)) as anon_1);
SELECT bar
FROM t
WHERE bar = ANY(SELECT anon_1 FROM (VALUES (1), (2), (42)) as anon_1) -- or s/ANY/ALL/ any/all behave the same as in. so 1 ok, 2 not ok. Calling SELECT bar
FROM t
WHERE bar IN (VALUES (1), (2), (42));
SELECT bar
FROM t
WHERE bar = ANY(VALUES (1), (2), (42)) -- or s/ANY/ALL/ |
but you mean to be using ALL/ANY in those sql examples right |
they actually work the same with both. Updated examples above |
Federico Caselli has proposed a fix for this issue in the main branch: Implement ScalarValue https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4183 |
Is your feature request related to a problem? Please describe.
Postgresql supports using
VALUES
as a column element, in query of the typeDescribe the solution you'd like
it would be nice if these two queries could be generated using
Describe alternatives you've considered
the first one produces
that does not work.
While the second raises the exception:
Using calling
table_valued()
does not produce the above query, generating inteadthis results in an error, at least on pg
Additional context
Since the current values is a from element, maybe this should be a pg only thing, that's not related to the global
values
?The current compile basically works so it could be reused for also for this new construct
Have a nice day!
The text was updated successfully, but these errors were encountered: