Created
February 16, 2009 21:44
-
-
Save copiousfreetime/65390 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Overwrite the quote column name since it quotes everything, but pk can return | |
| # a multiple columname for a pk, and when that is quoted it does not match any | |
| # column. | |
| if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" then | |
| module ActiveRecord | |
| module ConnectionAdapters | |
| class PostgreSQLAdapter | |
| if instance_methods.include?('quote_column_name') then | |
| unless instance_methods.include?( 'orig_quote_column_name' ) | |
| alias :orig_quote_column_name :quote_column_name | |
| # if it contains a , the there is a possiblity that it is a | |
| # composite colume, unless it already is quoted. If it has a , and | |
| # no " then split, quote and rejoin | |
| def quote_column_name( name ) | |
| s_name = name.to_s | |
| if s_name.index(',') then | |
| if s_name.index('"') then | |
| return orig_quote_column_name( name ) | |
| end | |
| parts = s_name.split(',') | |
| return parts.map {|c| orig_quote_column_name( c ) }.join(',') | |
| end | |
| orig_quote_column_name( name ) | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment