diff options
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb new file mode 100644 index 0000000000..0827f61db4 --- /dev/null +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -0,0 +1,34 @@ +require 'active_record/connection_adapters/sqlite_adapter' + +module ActiveRecord + class Base + # sqlite3 adapter reuses sqlite_connection. + def self.sqlite3_connection(config) # :nodoc: + parse_sqlite_config!(config) + + unless self.class.const_defined?(:SQLite3) + require_library_or_gem(config[:adapter]) + end + + db = SQLite3::Database.new( + config[:database], + :results_as_hash => true, + :type_translation => false + ) + + db.busy_timeout(config[:timeout]) unless config[:timeout].nil? + + ConnectionAdapters::SQLite3Adapter.new(db, logger) + end + end + + module ConnectionAdapters #:nodoc: + class SQLite3Adapter < SQLiteAdapter # :nodoc: + def table_structure(table_name) + returning structure = @connection.table_info(table_name) do + raise(ActiveRecord::StatementInvalid, "Could not find table '#{table_name}'") if structure.empty? + end + end + end + end +end |