# Postgres nonstandard use of \\\\ in a string literal

**URL:** <https://www.ruby-forum.com/t/postgres-nonstandard-use-of-in-a-string-literal/114344>\
**Category:** Rails\
**Created:** [September 11, 2007, 4:37pm UTC](https://www.ruby-forum.com/t/postgres-nonstandard-use-of-in-a-string-literal/114344 "2007-09-11T16:37:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jacob\_a](https://www.ruby-forum.com/u/jacob_a)\
**Post date:** [September 11, 2007, 4:37pm UTC](https://www.ruby-forum.com/t/postgres-nonstandard-use-of-in-a-string-literal/114344/1 "2007-09-11T16:37:54Z")

</div>

Hi list,

I have recently noticed the following warning in various places in  
regards to Rails and YAML serialized data:

WARNING: nonstandard use of \ in a string literal  
LINE 1: …ed\_at" = ‘2007-09-11 14:51:31’, “serialized\_replies” = ‘—  
^  
HINT: Use the escape string syntax for backslashes, e.g., E’\’.

It doesn’t seem to yield any problems. Is this a bug or a bad  
configuration on my part or something else?

–  
Cheers,

- Jacob A.

---

<div class="post-metadata">

**Author:** ![jacob\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jacob\_a](https://www.ruby-forum.com/u/jacob_a)\
**Post date:** [September 11, 2007, 5:24pm UTC](https://www.ruby-forum.com/t/postgres-nonstandard-use-of-in-a-string-literal/114344/2 "2007-09-11T17:24:05Z")

</div>

On Sep 11, 2007, at 9:29 , Jacob A. wrote:

> WARNING: nonstandard use of \ in a string literal  
> LINE 1: …ed\_at" = ‘2007-09-11 14:51:31’, “serialized\_replies” = ‘—  
> ^  
> HINT: Use the escape string syntax for backslashes, e.g., E’\’.
> 
> It doesn’t seem to yield any problems. Is this a bug or a bad  
> configuration on my part or something else?

Historically PostgreSQL has allowed c-style escapes (such as \n) in  
strings. As this does not comply with the SQL standard, the option to  
use treat \ as just any other character was introduced (in 8.1 IIRC,  
see standard\_conforming\_strings). As well, a new E-string syntax was  
added which allows you to use \ as an escape character.

You can set standard\_conforming\_strings in postgresql.conf or at the  
session level using SET. This should get rid of the warning. I’m not  
sure how the new version of the PostgreSQL adapter (in Edge) behaves,  
but you might want to look into that as well if you’re interested.

Michael G.  
grzm seespotcode net

---

<div class="post-metadata">

**Author:** ![jacob\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/2bfe46/32.png) [@jacob\_a](https://www.ruby-forum.com/u/jacob_a)\
**Post date:** [September 11, 2007, 9:33pm UTC](https://www.ruby-forum.com/t/postgres-nonstandard-use-of-in-a-string-literal/114344/3 "2007-09-11T21:33:42Z")

</div>

Michael G. wrote:

> Historically PostgreSQL has allowed c-style escapes (such as \n) in  
> strings. As this does not comply with the SQL standard, the option to  
> use treat \ as just any other character was introduced (in 8.1 IIRC,  
> see standard\_conforming\_strings). As well, a new E-string syntax was  
> added which allows you to use \ as an escape character.
> 
> You can set standard\_conforming\_strings in postgresql.conf or at the  
> session level using SET. This should get rid of the warning. I’m not  
> sure how the new version of the PostgreSQL adapter (in Edge) behaves,  
> but you might want to look into that as well if you’re interested.

Thanks for the information. I’ll check out edge to see if it’s fixed  
there.

–  
Cheers,

- Jacob A.
