提交 104d0b26 编写于 作者: A Aaron Patterson

adding backwards compatibility for non-prepare statement handling drivers

上级 fca229e2
......@@ -4,7 +4,15 @@ module DatabaseStatements
# Returns an array of record hashes with the column names as keys and
# column values as values.
def select_all(sql, name = nil, bind_values = [])
select(sql, name, bind_values)
if supports_statement_cache?
select(sql, name, bind_values)
else
return select(sql, name) if bind_values.empty?
binds = bind_values.dup
select sql.gsub('?') {
quote(*binds.shift.reverse)
}, name
end
end
# Returns a record hash with the column names as keys and column values
......@@ -42,7 +50,7 @@ def execute(sql, name = nil)
# Executes +sql+ statement in the context of this connection using
# +bind_values+ as the bind substitutes. +name+ is logged along with
# the executed +sql+ statement.
def exec(sql, name = nil, binds = [])
def exec(sql, name = 'SQL', binds = [])
end
# Returns the last auto-generated ID from the affected table.
......@@ -74,6 +82,12 @@ def outside_transaction?
nil
end
# Returns +true+ when the connection adapter supports prepared statement
# caching, otherwise returns +false+
def supports_statement_cache?
false
end
# Runs the given block in a database transaction, and returns the result
# of the block.
#
......
......@@ -203,6 +203,12 @@ def adapter_name #:nodoc:
ADAPTER_NAME
end
# Returns +true+ when the connection adapter supports prepared statement
# caching, otherwise returns +false+
def supports_statement_cache?
true
end
def supports_migrations? #:nodoc:
true
end
......
......@@ -211,6 +211,12 @@ def adapter_name
ADAPTER_NAME
end
# Returns +true+ when the connection adapter supports prepared statement
# caching, otherwise returns +false+
def supports_statement_cache?
true
end
# Initializes and connects a PostgreSQL adapter.
def initialize(connection, logger, connection_parameters, config)
super(connection, logger)
......
......@@ -62,6 +62,12 @@ def supports_ddl_transactions?
sqlite_version >= '2.0.0'
end
# Returns +true+ when the connection adapter supports prepared statement
# caching, otherwise returns +false+
def supports_statement_cache?
true
end
def supports_migrations? #:nodoc:
true
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册