Re: Allow disabling folding of unquoted identifiers to lowercase

From: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Allow disabling folding of unquoted identifiers to lowercase
Date: 2016-05-08 09:26:53
Message-ID: 20160508092653.GB27578@rorschach.hjp.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2016-04-29 19:21:30 +0200, Evgeny Morozov wrote:
> It would be great if Postgres had a server setting that allowed the automatic
> folding of identifiers to lowercase to be disabled, so that camel case
> identifiers could be used without having to quote every single identifier, i.e.
>
> SELECT MyColumn FROM MyTable ORDER BY MyColumn
>
> instead of
>
> SELECT "MyColumn" FROM "MyTable" ORDER BY "MyColumn"
[...]
> My company is looking into doing this. Currently our table and column names
> exactly match our class and property names, which are in camel case. MSSQL
> supports this just fine. To move to Postgres we would have to either quote
> *everything* or translate names back-and-forth between code and database. Both
> options are OK for auto-generated SQL, but we also have many users writing
> ad-hoc SQL queries. Having to quote everything would have those users screaming
> to switch back to MSSQL very quickly! That leaves us with the mapping approach,
> which is doable, but also a constant "mental speedbump" at best.

What exactly is the problem you are trying to solve?

If you and your users are consistent about never using quotes, your
users can write:

SELECT MyColumn FROM MyTable ORDER BY MyColumn;

It will select mycolumn from mytable, but that doesn't matter, since you
created the table with

CREATE MyTable (MyColumn varchar);

so you really have a table mytable with a column mycolumn, not a table
MyTable with a column MyColumn.

There are three potential problems I can see:

1) Users might be confused that PgAdmin (or whatever tool they use to
inspect the database) displays all the names in lowercase, and they
might find a name like sometablewithareallylongname less readable
than SomeTableWithAReallyLongName.

2) Since case doesn't matter, they might be inconsistent: One programmer
might write MyTable, another mytable, the third MYTABLE, ...

3) You might want to use a tool to automatically generate SQL queries,
but that tool quotes identifiers.

hp

--
_ | Peter J. Holzer | I want to forget all about both belts and
|_|_) | | suspenders; instead, I want to buy pants
| | | hjp(at)hjp(dot)at | that actually fit.
__/ | http://www.hjp.at/ | -- http://noncombatant.org/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Klaus P. Pieper 2016-05-08 09:41:03 Re: Allow disabling folding of unquoted identifiers to lowercase
Previous Message Jasim Mohd 2016-05-08 08:59:56 Postgres RFC3339 datetime formatting