提交 3f4cbccb 编写于 作者: J Jamis Buck

When dealing with SQLite3, use the table_info pragma helper, so that the...

When dealing with SQLite3, use the table_info pragma helper, so that the bindings can do some translation for when sqlite3 breaks incompatibly between point releases. Also, make current_adapter? use is_a? instead of instance_of? to account correctly for adapter subclassing.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6091 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 d5e12200
*SVN*
* When dealing with SQLite3, use the table_info pragma helper, so that the bindings can do some translation for when sqlite3 breaks incompatibly between point releases. [Jamis Buck]
* Oracle: fix lob and text default handling. #7344 [gfriedrich, Michael Schoen]
* SQLServer: don't choke on strings containing 'null'. #7083 [Jakob S]
......
......@@ -22,7 +22,7 @@ def sqlite3_connection(config) # :nodoc:
db.busy_timeout(config[:timeout]) unless config[:timeout].nil?
ConnectionAdapters::SQLiteAdapter.new(db, logger)
ConnectionAdapters::SQLite3Adapter.new(db, logger)
end
# Establishes a connection to the database that's used by all Active Record objects
......@@ -381,6 +381,14 @@ def default_primary_key_type
end
end
class SQLite3Adapter < SQLiteAdapter # :nodoc:
def table_structure(table_name)
returning structure = @connection.table_info(table_name) do
raise ActiveRecord::StatementInvalid if structure.empty?
end
end
end
class SQLite2Adapter < SQLiteAdapter # :nodoc:
def supports_count_distinct? #:nodoc:
false
......
......@@ -56,7 +56,7 @@ def assert_no_queries(&block)
def current_adapter?(*types)
types.any? do |type|
ActiveRecord::ConnectionAdapters.const_defined?(type) &&
ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters.const_get(type))
ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters.const_get(type))
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册