Class: ActiveRecord::ConnectionAdapters::SQLite3Adapter

Inherits:
AbstractAdapter
  • Object
show all
Includes:
ArJdbc::Abstract::ConnectionManagement, ArJdbc::Abstract::Core, ArJdbc::Abstract::DatabaseStatements, ArJdbc::Abstract::StatementCache, ArJdbc::Abstract::TransactionSupport, ArJdbc::SQLite3
Defined in:
lib/arjdbc/sqlite3/adapter.rb

Overview

Currently our adapter is named the same as what AR5 names its adapter. We will need to get this changed at some point so this can be a unique name and we can extend activerecord ActiveRecord::ConnectionAdapters::SQLite3Adapter. Once we can do that we can remove the module SQLite3 above and remove a majority of this file.

Constant Summary

Constants included from ArJdbc::Abstract::DatabaseStatements

ArJdbc::Abstract::DatabaseStatements::NO_BINDS

Constants included from ArJdbc::SQLite3

ArJdbc::SQLite3::ADAPTER_NAME, ArJdbc::SQLite3::ConnectionAdapters, ArJdbc::SQLite3::IndexDefinition, ArJdbc::SQLite3::NATIVE_DATABASE_TYPES, ArJdbc::SQLite3::Quoting, ArJdbc::SQLite3::RecordNotUnique, ArJdbc::SQLite3::SQLite3Adapter, ArJdbc::SQLite3::SchemaCreation

Instance Attribute Summary

Attributes included from ArJdbc::Abstract::Core

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ArJdbc::Abstract::TransactionSupport

#begin_db_transaction, #commit_db_transaction, #create_savepoint, #exec_rollback_db_transaction, #exec_rollback_to_savepoint, #release_savepoint, #supports_savepoints?

Methods included from ArJdbc::Abstract::StatementCache

#clear_cache!, #delete_cached_statement, #fetch_cached_statement, #initialize

Methods included from ArJdbc::Abstract::DatabaseStatements

#exec_query, #exec_update, #execute, #select_all

Methods included from ArJdbc::Abstract::ConnectionManagement

#active?, #disconnect!, #really_valid?, #reconnect!

Methods included from ArJdbc::SQLite3

#add_column, #add_reference, #allowed_index_name_length, #begin_db_transaction, #build_insert_sql, #build_truncate_statements, #change_column, #change_column_default, #change_column_null, #check_version, #commit_db_transaction, #disable_referential_integrity, #encoding, #exec_rollback_db_transaction, #explain, #foreign_keys, #get_database_version, #initialize, #insert_fixtures_set, #last_inserted_id, #native_database_types, #primary_keys, #remove_column, #remove_index, #rename_column, #rename_table, #requires_reloading?, #supports_datetime_with_precision?, #supports_ddl_transactions?, #supports_explain?, #supports_expression_index?, #supports_foreign_keys?, #supports_index_sort_order?, #supports_insert_on_conflict?, #supports_json?, #supports_lazy_transactions?, #supports_partial_index?, #supports_savepoints?, #supports_views?, #write_query?

Methods included from ArJdbc::Abstract::Core

#extract_raw_bind_values, #initialize, #jdbc_connection, #log, #translate_exception, #translate_exception_class

Class Method Details

.database_exists?(config) ⇒ Boolean

Returns:

  • (Boolean)


645
646
647
648
649
650
651
652
653
# File 'lib/arjdbc/sqlite3/adapter.rb', line 645

def self.database_exists?(config)
  config = config.symbolize_keys
  if config[:database] == ":memory:"
    return true
  else
    database_file = defined?(Rails.root) ? File.expand_path(config[:database], Rails.root) : config[:database]
    File.exist?(database_file)
  end
end

.jdbc_connection_classObject



680
681
682
# File 'lib/arjdbc/sqlite3/adapter.rb', line 680

def self.jdbc_connection_class
  ::ActiveRecord::ConnectionAdapters::SQLite3JdbcConnection
end

.represent_boolean_as_integer=(value) ⇒ Object

:nodoc:



635
636
637
638
639
640
641
642
643
# File 'lib/arjdbc/sqlite3/adapter.rb', line 635

def self.represent_boolean_as_integer=(value) # :nodoc:
  if value == false
    raise "`.represent_boolean_as_integer=` is now always true, so make sure your application can work with it and remove this settings."
  end

  ActiveSupport::Deprecation.warn(
    "`.represent_boolean_as_integer=` is now always true, so setting this is deprecated and will be removed in Rails 6.1."
  )
end

Instance Method Details

#begin_isolated_db_transaction(isolation) ⇒ Object

Raises:

  • (ActiveRecord::TransactionIsolationError)


660
661
662
# File 'lib/arjdbc/sqlite3/adapter.rb', line 660

def begin_isolated_db_transaction(isolation)
  raise ActiveRecord::TransactionIsolationError, 'adapter does not support setting transaction isolation'
end

#exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil) ⇒ Object

SQLite driver doesn't support all types of insert statements with executeUpdate so make it act like a regular query and the ids will be returned from #last_inserted_id example: INSERT INTO "aircraft" DEFAULT VALUES



667
668
669
# File 'lib/arjdbc/sqlite3/adapter.rb', line 667

def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil)
  exec_query(sql, name, binds)
end

#jdbc_column_classObject



671
672
673
# File 'lib/arjdbc/sqlite3/adapter.rb', line 671

def jdbc_column_class
  ::ActiveRecord::ConnectionAdapters::SQLite3Column
end

#jdbc_connection_class(spec) ⇒ Object



675
676
677
# File 'lib/arjdbc/sqlite3/adapter.rb', line 675

def jdbc_connection_class(spec)
  self.class.jdbc_connection_class
end

#supports_transaction_isolation?Boolean

Returns:

  • (Boolean)


656
657
658
# File 'lib/arjdbc/sqlite3/adapter.rb', line 656

def supports_transaction_isolation?
  false
end