Re: PostgreSQL Developer Best Practices - Mailing list pgsql-general

From David G. Johnston
Subject Re: PostgreSQL Developer Best Practices
Date
Msg-id CAKFQuwYAphnk_=D4Ymgp+tvYa1jg04qXUt7miJUWhCfxLuvMRA@mail.gmail.com
Whole thread Raw
In response to Re: PostgreSQL Developer Best Practices  (Melvin Davidson <melvin6925@gmail.com>)
List pgsql-general
On Saturday, August 22, 2015, Melvin Davidson <melvin6925@gmail.com> wrote:
>The correct way to escape a quote is to double quote it:  'Mr. M''vey'

That is a matter of opinion. However, the real problem is the enclosed backslashes, which is
beyond our control at this point. Therefore, the best solution is to use ESCAPE E.


Why is this a best practice and not just "how things work"?  If you want to use backlash escapes you use E''.  If you don't use a backslash escape it doesn't matter - except if you are writing a backslash and don't want to have to escape it.

Beyond that turn your idea of best practice into a requirement and enable standard-conforming-strings.

Always using E'' is pragmatic advice but hardly worthy of being considered best practice.  The best practice is to write code in such a way that you can leave standard conforming strings off AND not generate any warnings.

David J.


pgsql-general by date:

Previous
From: Melvin Davidson
Date:
Subject: Re: PostgreSQL Developer Best Practices
Next
From: John R Pierce
Date:
Subject: Re: PostgreSQL Developer Best Practices