[Sqlalchemy-tickets] Issue #4325: Parameters in pgsql DISTINCT ON () not getting bound (zzzeek/sqla
Brought to you by:
zzzeek
From: Robert B. <iss...@bi...> - 2018-08-22 20:47:23
|
New issue 4325: Parameters in pgsql DISTINCT ON () not getting bound https://bitbucket.org/zzzeek/sqlalchemy/issues/4325/parameters-in-pgsql-distinct-on-not Robert Bertorelli: Hello, I've run into the following issue in sqlalchemy 1.2.11. I looked through the already-extant bugs and didn't find this. In the postgresql dialect, parameters within a DISTINCT ON clause will not be bound. Here's a simple example using python 3.6: ``` #!python >>> import sqlalchemy as sa >>> from sqlalchemy.dialects import postgresql as pg >>> col = sa.column('name') >>> col2 = col == 'foo' >>> sel = sa.select([col2]).distinct(col2) >>> print(sel.compile(dialect=pg.dialect(), compile_kwargs={"literal_binds": True})) SELECT DISTINCT ON (name = %(name_1)s) name = 'foo' AS anon_1 ``` So, as you can see, the parameter in the SELECT statement (name = 'foo') did get bound properly, but the same column in the DISTINCT ON did not. I believe that the issue can be found here: https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/dialects/postgresql/base.py#L1528 Seems like `**kw` needs to get passed into self.process(). Thanks. |