quote_string don't work with some postgres drivers
Reported by Lars Kanis | May 2nd, 2008 @ 09:24 AM
A special code path is used for postgres drivers that don't define PGconn.escape. This code path does not work and throws the following exception.
Attached is a patch with the simple fix.
d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:352:in `quote_string': undefined method `quote_string' for # (NoMethodError)
from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/quoting.rb:19:in `quote'
from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:333:in `quote'
from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1880:in `quote_bound_value'
from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1851:in `replace_bind_variables'
from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1851:in `gsub'
from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1851:in `replace_bind_variables'
from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1819:in `sanitize_sql_hash_for_conditions'
from d:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1778:in `sanitize_sql'
Comments and changes to this ticket
-
Stephen Celis May 10th, 2008 @ 02:11 PM
- → Title changed from [FIX] quote_string don't work with some postgres drivers to quote_string don't work with some postgres drivers
-
Pratik May 20th, 2008 @ 06:57 PM
- → State changed from new to incomplete
Can you please provide with more informations to reproduce this ?
Thanks.
-

Lars Kanis May 21st, 2008 @ 02:08 PM
Thanks for answering.
Attached you can find a i386-msvcrt-compiled older version (0.7.1) of the postgres-driver. With this version any database activity will result in the exception above.
This driver doesn't define PGconn.escape. In this case the postgresql_adapter.rb should use the quote_string() from quoting.rb.
But what the quote_string() in postgresql_adapter.rb actually does, is to remove quote_string() entirely from the base class too. So undef_method needs to be changed to remove_method.
Pre ActiveRecord 2.0 versions didn't use PGconn.escape, so the attached binary driver worked out of the box.
Hope the report is more complete now.
-
Pratik May 21st, 2008 @ 08:15 PM
- → State changed from incomplete to open
-
Joshua Peek July 17th, 2008 @ 01:54 AM
- → Assigned user changed from to Jeremy Kemper
- → Tag changed from to activerecord patch
-

Repository August 28th, 2008 @ 06:52 AM
- → State changed from open to resolved
(from [79c3f73a7ff9452d1692c6150f8a7503d8afd459]) PostgreSQL: fix quote_string for certain old pg drivers. [#94 state:resolved] http://github.com/rails/rails/co...
-

Repository August 28th, 2008 @ 06:52 AM
(from [b23b19109050af04e2e1d0f57aee306463f4cbb9]) PostgreSQL: fix quote_string for certain old pg drivers. [#94 state:resolved] http://github.com/rails/rails/co...
-

Repository August 28th, 2008 @ 06:52 AM
(from [c2068d14d29ec767c681798b3814f0a8e22fb0ff]) PostgreSQL: fix quote_string for certain old pg drivers. [#94 state:resolved] http://github.com/rails/rails/co...
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Source available from github
The Git repository resides at http://github.com/rails
Check out the current development trunk (Edge Rails) with:
git clone git://github.com/rails/rails.git
Creating or reviewing a patch
See the contributor guide.
Creating a feature request
Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.
Creating a bug report
When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.
Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.
Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too".
