On Sat, 14 Apr 2018 19:25:48 -0700 (PDT)
Maximiliano Robaina <maxiroba...@gmail.com> wrote:
> Testing expressions test app, the query generated into
> BasicExpressionsTests.test_annotate_values_filter method:
> companies = Company.objects.annotate(
> foo=RawSQL('%s', ['value']),
> 'SELECT "EXPRESSIONS_COMPANY"."ID", "EXPRESSIONS_COMPANY"."NAME",
> "EXPRESSIONS_COMPANY"."NUM_CHAIRS", "EXPRESSIONS_COMPANY"."CEO_ID",
> "EXPRESSIONS_COMPANY"."POINT_OF_CONTACT_ID", ? AS "FOO" FROM
> "EXPRESSIONS_COMPANY" WHERE ? = ? ORDER BY
> "EXPRESSIONS_COMPANY"."NAME" ASC'
> This sql command has 3 params (?), two of which are out of where
> ? AS "FOO"
> WHERE ? = ?
A few years ago something similar was causing issues with the Oracle
backend. To resolve it, Mariusz added a clevar hack, relying on named
parameters -- he made sure that if the same parameter value is used
more than once, then the statement re-uses the parameter name, passing
the value only once. So, in your case, the equivalent would be
"EXPRESSIONS_COMPANY"."POINT_OF_CONTACT_ID", %arg1 AS "FOO" FROM
"EXPRESSIONS_COMPANY" WHERE %arg1 = %arg1 ORDER BY
cursor.execute(sql, , arg1='value')
This was relatively easy to do in the Oracle backend, which has always
used named parameters under the hood (though the idea to do it was, in
my opinion, surprising and brilliant). If Firebird supports them, you
may be able to borrow this solution.
You received this message because you are subscribed to the Google Groups
"Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email
To post to this group, send email to email@example.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
For more options, visit https://groups.google.com/d/optout.