Skip to content

Commit

Permalink
Merge pull request #134 from rainerborene/rails4.1
Browse files Browse the repository at this point in the history
Use schema cache to look up predicate columns
  • Loading branch information
danmcclain committed Jul 21, 2014
2 parents 091dc7e + bcceeea commit 57bded6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.build(attribute, value)
case value
when Array
engine = attribute.relation.engine
column = engine.connection.columns(attribute.relation.name).detect{ |col| col.name.to_s == attribute.name.to_s }
column = engine.connection.schema_cache.columns(attribute.relation.name).detect{ |col| col.name.to_s == attribute.name.to_s }
if column && column.array
attribute.eq(value)
else
Expand Down
2 changes: 1 addition & 1 deletion lib/postgres_ext/arel/visitors/to_sql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Arel
module Visitors
class ToSql
def visit_Array o, a
column = a.relation.engine.connection.columns(a.relation.name).find { |col| col.name == a.name.to_s } if a
column = a.relation.engine.connection.schema_cache.columns(a.relation.name).find { |col| col.name == a.name.to_s } if a
if column && column.respond_to?(:array) && column.array
quoted o, a
else
Expand Down
1 change: 1 addition & 0 deletions lib/postgres_ext/arel/visitors/visitor.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'arel/visitors/visitor'

module Arel
module Visitors
class Visitor
Expand Down

0 comments on commit 57bded6

Please sign in to comment.