module ActiveRecord::Import::SQLite3Adapter
Constants
- MIN_VERSION_FOR_IMPORT
- MIN_VERSION_FOR_UPSERT
- SQLITE_LIMIT_COMPOUND_SELECT
Public Instance Methods
database_version()
click to toggle source
Calls superclass method
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 177 def database_version defined?(sqlite_version) ? sqlite_version : super end
next_value_for_sequence(sequence_name)
click to toggle source
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 68 def next_value_for_sequence(sequence_name) %{nextval('#{sequence_name}')} end
pre_sql_statements( options )
click to toggle source
Calls superclass method
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 48 def pre_sql_statements( options ) sql = [] # Options :recursive and :on_duplicate_key_ignore are mutually exclusive if !supports_on_duplicate_key_update? && (options[:ignore] || options[:on_duplicate_key_ignore]) sql << "OR IGNORE" end sql + super end
sql_for_conflict_target( args = {} )
click to toggle source
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 157 def sql_for_conflict_target( args = {} ) conflict_target = args[:conflict_target] index_predicate = args[:index_predicate] if conflict_target.present? sql = "(#{Array( conflict_target ).reject( &:blank? ).join( ', ' )}) " sql += "WHERE #{index_predicate} " if index_predicate sql end end
sql_for_default_conflict_target( primary_key )
click to toggle source
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 167 def sql_for_default_conflict_target( primary_key ) conflict_target = Array(primary_key).join(', ') "(#{conflict_target}) " if conflict_target.present? end
supports_import?()
click to toggle source
Override our conformance to ActiveRecord::Import::ImportSupport
interface to ensure that we only support import in supported version of SQLite. Which INSERT statements with multiple value sets was introduced in 3.7.11.
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 14 def supports_import? database_version >= MIN_VERSION_FOR_IMPORT end
supports_on_duplicate_key_update?()
click to toggle source
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 18 def supports_on_duplicate_key_update? database_version >= MIN_VERSION_FOR_UPSERT end