Skip to content

Commit

Permalink
Use the schema_search_path in prepared statements.
Browse files Browse the repository at this point in the history
To allow the use of prepared statements when changing schemas in
postgres, the schema search path is added to the sql key.
  • Loading branch information
Juanmcuello committed Oct 5, 2011
1 parent c495bfc commit cfc95d8
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1035,13 +1035,14 @@ def exec_no_cache(sql, binds)
end

def exec_cache(sql, binds)
unless @statements.key? sql
sql_key = "#{schema_search_path}-#{sql}"
unless @statements.key? sql_key
nextkey = @statements.next_key
@connection.prepare nextkey, sql
@statements[sql] = nextkey
@statements[sql_key] = nextkey
end

key = @statements[sql]
key = @statements[sql_key]

# Clear the queue
@connection.get_last_result
Expand Down

0 comments on commit cfc95d8

Please sign in to comment.