module ActiveRecord::Import::SQLite3Adapter
Constants
- MIN_VERSION_FOR_IMPORT
- MIN_VERSION_FOR_UPSERT
- SQLITE_LIMIT_COMPOUND_SELECT
Public Instance Methods
increment_locking_column!(results, locking_column)
click to toggle source
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 173 def increment_locking_column!(results, locking_column) if locking_column.present? results << "\"#{locking_column}\"=EXCLUDED.\"#{locking_column}\"+1" end end
next_value_for_sequence(sequence_name)
click to toggle source
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 71 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 49 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 153 def sql_for_conflict_target( args = {} ) conflict_target = args[:conflict_target] index_predicate = args[:index_predicate] if conflict_target.present? '(' << Array( conflict_target ).reject( &:blank? ).join( ', ' ) << ') '.tap do |sql| sql << "WHERE #{index_predicate} " if index_predicate end end end
sql_for_default_conflict_target( primary_key )
click to toggle source
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 163 def sql_for_default_conflict_target( primary_key ) conflict_target = Array(primary_key).join(', ') "(#{conflict_target}) " if conflict_target.present? end
supports_import?(current_version = sqlite_version)
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 12 def supports_import?(current_version = sqlite_version) if current_version >= MIN_VERSION_FOR_IMPORT true else false end end
supports_on_duplicate_key_update?(current_version = sqlite_version)
click to toggle source
# File lib/activerecord-import/adapters/sqlite3_adapter.rb, line 20 def supports_on_duplicate_key_update?(current_version = sqlite_version) current_version >= MIN_VERSION_FOR_UPSERT end