Re: rationale behind quotes for camel case?

Поиск
Список
Период
Сортировка
От Greg Smith
Тема Re: rationale behind quotes for camel case?
Дата
Msg-id 4E0A3BA2.9070507@2ndquadrant.com
обсуждение исходный текст
Ответ на rationale behind quotes for camel case?  (fluca1978@infinito.it)
Список pgsql-general
fluca1978@infinito.it wrote:
> first of all I'm not expressing any critique against the use of quotes
> for identifier expressed using camel case. However a lot of new
> postgresql users seems to be unhappy with the use of quotes for camel
> case identifiers, so I'd like to know what is the rationale behind it.
> I mean, is a feature of the partser or is a need for it to work?
> Anyone can point me to an explaination?

The need for quoting and use of CamelCase are only vaguely related to
one another.  There are situations other than CamelCase where quotes are
needed, and using CamelCase doesn't necessarily require quotes.

If you follow the end of the documentation at
http://www.postgresql.org/docs/9.0/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
you'll find this explanation of what the quoting issue is all about:

  Quoting an identifier also makes it case-sensitive, whereas unquoted
names are always folded to lower case. For example, the identifiers FOO,
foo, and "foo" are considered the same by PostgreSQL, but "Foo" and
"FOO" are different from these three and each other. (The folding of
unquoted names to lower case in PostgreSQL is incompatible with the SQL
standard, which says that unquoted names should be folded to upper case.
Thus, foo should be equivalent to "FOO" not "foo" according to the
standard. If you want to write portable applications you are advised to
always quote a particular name or never quote it.)

So saying you're unhappy with the need for quoting of mixed-case items
isn't going to get you very far, as the behavior here is all tied up
with the trivia of the SQL spec.  The specification intends that
anything other than all upper-case naming requires quoting, and
PostgreSQL turns that around to say that everything goes to lower-case
by default.  It's actually possible to leave out the quoting if you
really want to, but as advised here you have to be consistent about it.
Once you've created something with a fully quoted name, instead of
letting it "fold" the name to all lower-case, you must continue to
reference it that way in the future.  There's nothing stopping you from
just never quoting anything though.

--
Greg Smith   2ndQuadrant US    greg@2ndQuadrant.com   Baltimore, MD
Comprehensive and Customized PostgreSQL Training Classes:
http://www.2ndquadrant.us/postgresql-training/


В списке pgsql-general по дате отправления:

Предыдущее
От: dennis jenkins
Дата:
Сообщение: Re: rationale behind quotes for camel case?
Следующее
От: Karsten Hilbert
Дата:
Сообщение: Re: rationale behind quotes for camel case?