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

**URL:** <https://discuss.rubyonrails.org/t/postgres-nonstandard-use-of-in-a-string-literal/18034>\
**Category:** rubyonrails-talk\
**Created:** [September 11, 2007, 2:29pm UTC](https://discuss.rubyonrails.org/t/postgres-nonstandard-use-of-in-a-string-literal/18034 "2007-09-11T14:29:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob\_Atzen](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@Jacob\_Atzen](https://discuss.rubyonrails.org/u/Jacob_Atzen)\
**Post date:** [September 11, 2007, 2:29pm UTC](https://discuss.rubyonrails.org/t/postgres-nonstandard-use-of-in-a-string-literal/18034/1 "2007-09-11T14:29:30Z")

</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" = '--- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^ 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?

---

<div class="post-metadata">

**Author:** ![Michael\_Glaesemann](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@Michael\_Glaesemann](https://discuss.rubyonrails.org/u/Michael_Glaesemann)\
**Post date:** [September 11, 2007, 3:21pm UTC](https://discuss.rubyonrails.org/t/postgres-nonstandard-use-of-in-a-string-literal/18034/2 "2007-09-11T15:21:34Z")

</div>

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 Glaesemann grzm seespotcode net

---

<div class="post-metadata">

**Author:** ![Jacob\_Atzen](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@Jacob\_Atzen](https://discuss.rubyonrails.org/u/Jacob_Atzen)\
**Post date:** [September 11, 2007, 7:16pm UTC](https://discuss.rubyonrails.org/t/postgres-nonstandard-use-of-in-a-string-literal/18034/3 "2007-09-11T19:16:13Z")

</div>

Michael Glaesemann wrote:

> > WARNING: nonstandard use of \\ in a string literal LINE 1: ...ed\_at" = '2007-09-11 14:51:31', "serialized\_replies" = '--- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;^ 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.

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