|Schema tests and .extra queryset method||Maximiliano Robaina||21/05/14 15:38|
Running schema tests I caught an issue, more precisely, in test_add_field_default_transform.
At the end, this test method is doing:
self.assertEqual(Author.objects.extra(where=["thing = 1"]).count(), 2)
The problem here is what in this where clause, the "thing" field must be quoted.
In firebird :
SELECT * FROM AUTHOR WHERE thing = 1 <-- Here thing (in lowercase) and THING (in uppercase) are equivalent, are the same object
is different of:
SELECT * FROM AUTHOR WHERE "thing" = 1 <-- field is quoted
For a more generic test I think we need to avoid use .extra method or another raw sql statement.
|Re: Schema tests and .extra queryset method||Russell Keith-Magee||21/05/14 17:06|
Thanks for letting us know. If you find a problem like this, the best way to report it is to open a ticket in Trac. That way we have a permanent record of the existence of the issue, and we can mark the issue as resolved when a fix is applied to the source tree. It also allows us to flag and triage specific issues so that we know they get addressed before a release.
Russ Magee %-)
|Re: Schema tests and .extra queryset method||Shai Berger||21/05/14 23:24|
The issue of case in quoted and un-quoted names in SQL is indeed a sad mess,
bad decisions made in the 1960s that we still need to live with today.
Quoting it uncoditionally would break the test on Oracle (which, by default,
turns all the names to uppercase). There is a feature-flag for it...
...but I agree -- an "extra" should not be needed at all in this specific test.
The Author model has the added column as a field.
|Re: Schema tests and .extra queryset method||Maximiliano Robaina||22/05/14 6:52|
El miércoles, 21 de mayo de 2014 21:06:22 UTC-3, Russell Keith-Magee escribió:
|Re: Schema tests and .extra queryset method||Maximiliano Robaina||22/05/14 7:06|
El jueves, 22 de mayo de 2014 03:24:12 UTC-3, Shai Berger escribió:
How this feature flag should works?
I see that Oracle backend is always making an upper in DatabaseOperations.quote_name, therefore, how does Oracle pass test like  where it is using field name in lowecase  ?
|Re: Schema tests and .extra queryset method||Shai Berger||26/05/14 17:19|
Sorry for the delay in responding to this.
> > Quoting it uncoditionally would break the test on Oracle (which, byIt's called "uppercases_column_names". The way it should work is -- it should
be False for backends that don't change the case of names, and True for Oracle
(currently, it is actually reversed; fixing it is on my to-do, but I haven't
gotten to it yet).
It lowercases the name back in introspection
And yes, this behavior completely breaks things if you try to really use
lowercase in names. I am on record describing the Oracle backend's behavior as
"case-insane", but this cannot be changed without breaking backwards
(FWIW, I believe the SQL standard says that unquoted names should be case-
insensitive, which, in turn, means introspection more-or-less must be broken.
uppercasing unquoted input was standard back in the 1960s -- it was an easy
way to differentiate user input from computer output in a time when the
interface was a one-color, one-font teletype. Regretfully, we now need to deal
with the consequences.)