Julian Scheid wrote:
>
> Hi,
>
> for hsqldb - which I'd like to support with my driver - I need to
> quote all identifiers so that it preserves case. Otherwise it converts
> everything to uppercase which causes all sorts of trouble.
>
> (I could also change the case in SQLalchemy objects like the MySQL
> driver does, but that will break as soon as things need to be quoted,
> for example identifiers that look like keywords - so I figure I might
> as well just quote everything.)
>
> There are a number of tests in test_reflection.py that ignore the
> quoting preferences configured with the IdentifierPreparer:
> test_composite_pks, test_pks_not_uniques, and test_iteration.
>
> Is there anything speaking against changing these tests so that they
> don't use verbatim SQL code? For that matter, is there any reason why
> the dialect shouldn't force quoting for everything?

we don't force quoting because we deal with identifiers in a
case-insensitive manner by default.  SQLAlchemy considers any identifier
specified as "all lowercase" as case insensitive, and any identifier that
has any uppercase characters as case sensitive.    The database OTOH may
use all lower case or all upper case for case insensitive names.

Assuming hsqldb supports case insensitive identifiers as UPPERCASE, use
the same approach taken in the Firebird and Oracle dialects which both
work the same way, that is, include "requires_name_normalize=True", and
implement normalize_name() and denormalize_name().

As far as the specific unit tests named, assuming hsqldb works like
FB/oracle, the non-quoted names end up being created as case insensitive,
and come back during reflection as UPPERCASE - then normalize_name() takes
over.

I took a quick look at hsqldb's docs and this appears to be the case:

A unquoted identifier (name) starts with a letter and is followed by any
number of ASCII letters or digits. When an SQL statement is issued, any
lowercase characters in unquoted identifiers are converted to uppercase.
Because of this, unquoted names are in fact ALL UPPERCASE when used in SQL
statements. An important implication of this is the for accessing columns
names via JDBC DatabaseMetaData: the internal form, which is the ALL
UPPERCASE must be used if the column name was not quoted in the CREATE
TABLE statement.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to