[sqlalchemy] Re: Quoting column names on table create?
Karlo Lozovina wrote: I was just wondering, why does SA quote column names that have mixed case in them, and leaves them unquoted for lowercase column names? Because in general SQL engines tend to be case-insensitive, that is, under most of them the query SELECT column_a, column_b FROM table is perfectly equivalent to SELECT COLUMN_A, Column_B FROM Table To preserve the case of the entities you have to quote them (for example because you have two distinct tables, table and Table): this forces the engine to take the name literally, so that the first query above is *not* equivalent to the following SELECT column_a, column_b FROM table at least not when the default case used by the engine is uppercase (just imagine that the database server change every non-quoted entity name to either upper- or lower-case, and you are close to the fact :) So when SA thinks that the entity name it is handling is case sensitive (that always is when the name is CamelCased) it put automatically put quotes around it. Hope this clarifies a little, ciao, lele. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: Quoting column names on table create?
because a) SQL-standard says names are caseless - Fun anf fUn are same thing b) most SQLs allow mixed case but require it in quotes, and some are _very_ picky about it (postgres) c) readability - lowercase names differs well from uppercase reserved words On Thursday 15 March 2007 06:26:03 Karlo Lozovina wrote: Hi guys, I was just wondering, why does SA quote column names that have mixed case in them, and leaves them unquoted for lowercase column names? Here is what echo looks like: CREATE TABLE songs ( key INTEGER NOT NULL, path TEXT, name TEXT, price INTEGER, fileHash TEXT, PRIMARY KEY (key) ) And yes, I know it's a stupid and irrlevant question, but I was just wondering why does it do like this? Btw, I'm using SQLite in this example. Thanks, and once more, sorry for the stupid question :, Klm. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~--~~~~--~~--~--~---