Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[Patch] Postgres support for standard_conforming_strings = on

#2412

Many ActiveRecord PG unit tests failed on PG 8.3.6 if standard_conforming_strings was set to "on"

E should only be prefixed for standard_conforming_strings = off E was also being prefixed for standard_conforming_strings = on due to a bug.

Attached patch fixes the existing logic.

I'll attach the original AR tests logs indicating the error.

Reported by Joe Rafaniello · April 3rd, 2009 @ 09:13 PM

State: duplicate
Milestone: 2.3.6
Assigned to: Tarmo Tänav Tarmo Tänav
Importance: none

Activity

  1. Joe Rafaniello
    Joe Rafaniello

    The patch addresses the following errors in the attached AR unit test log:

    1) Failure: test_quote(BasicsTest)

    [./test/cases/base_test.rb:1478:in `test_quote'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__'
     ./test/cases/../../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `run']:
    
    

    <"\ \001 ' \n \n ""> expected but was <" \001 ' \n \n "">.

    2) Error: test_load_save(BinaryTest): ActiveRecord::StatementInvalid: PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xff

    There are several of the invalid byte sequence errors and a few quoting issues also in the log.

    April 3rd, 2009 @ 09:18 PM

  2. Joe Rafaniello
    Joe Rafaniello

    Can this patch be moved upstream?

    January 27th, 2010 @ 04:28 PM

  3. Marcin Mańk
    Marcin Mańk
    • Tag changed from 2.3.x, edge, postgres to 2, edge, postgres

    The regex should be /(1|t|true|on)/i , not /[1|t|true|on]/i

    February 4th, 2010 @ 11:02 PM

  4. Marcin Mańk
  5. ...Paul
    ...Paul
    • Tag changed from 2, edge, postgres to 2, 2.3.5, edge, postgres

    Ah, this bug was already filed, great. I sparked some commentary on the wrong, bug, issue #1837 PostgresSQLAdapter#unescape_bytea does not handle "\\", that may have some bearing. It looks like the patch is already done, but one thing to keep in mind is that the patch is making an assumption that the underlying library is doing the right thing by not escaping backslashes when scs is "on". While this is probably the safe bet, since I believe the postgres 0.79 gem, and definitely the pg gem (v0.8 and 0.9) both do "the right thing", if there are any legacy libs out there (not sure if the ruby-postgres gem is still in use, or if it does the "right thing", for example), that would escape backslashes even when scs is "on", then the E prefix needs to be used. To be absolutely complete, the code should be checking if the result of a call to quote() returns an escaped backslash -- if it does, then the E prefix needs to be used, regardless of whether or not the server is reporting scs "on".

    It would really be good, for sure, to get this into 2.3.6 if possible.

    March 10th, 2010 @ 12:29 AM

  6. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 2.3.6
    • State changed from new to duplicate

    Pending a tested patch that feature-checks the driver.

    March 10th, 2010 @ 04:46 PM

  7. Andrea Campi
    Andrea Campi
    • Tag changed from 2, 2.3.5, edge, postgres to 2-3-stable, 2.3.5, edge, postgres
    • Importance changed from to

    October 16th, 2010 @ 11:43 PM

  8. Julian Mehnle
    Julian Mehnle
    • Tag cleared.

    So, Jeremy, which bug is this one a duplicate of?

    March 15th, 2011 @ 01:31 AM

  9. Julian Mehnle
    Julian Mehnle
    • Tag set to 2-32-3-stable, 2.3.5, edge, postgres

    March 15th, 2011 @ 01:32 AM

  10. Julian Mehnle
    Julian Mehnle
    • Tag changed from 2-32-3-stable, 2.3.5, edge, postgres to 2-3-stable, 2.3.5, edge, postgres

    March 15th, 2011 @ 01:33 AM