Hi,
Testing expressions test app, the query generated into
BasicExpressionsTests.test_annotate_values_filter method:
companies = Company.objects.annotate(
foo=RawSQL('%s', ['value']),
).filter(foo='value').order_by('name')
Generate:
'SELECT "EXPRESSIONS_COMPANY"."ID", "EXPRESSIONS_COMPANY"."NAME",
"EXPRESSIONS_COMPANY"."NUM_EMPLOYEES", "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 clause.
? AS "FOO"
WHERE ? = ?
So, the underlying database driver execute this, doing something like this
cursor.execute(sql, ['value', 'value', 'value'])
Is correct that the 3 params are replaced into the entire sql and not just
on where clause ?
It depend of the implementation on each database driver?
Best regards
Maxi
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/5570530d-696d-4f6e-b557-eb84be410661%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.