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.

Defined Under Namespace

Classes: SQLite3Integer

Constant Summary collapse

TYPE_MAP =
ActiveRecord::Type::TypeMap.new.tap { |m| initialize_type_map(m) }

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

#active?, #add_column, #add_reference, #all_foreign_keys_valid?, #build_insert_sql, #change_column, #change_column_default, #change_column_null, #check_version, #disable_referential_integrity, #disconnect!, #encoding, #foreign_keys, #get_database_version, #initialize, #native_database_types, #primary_keys, #reconnect!, #remove_column, #remove_columns, #remove_index, #rename_column, #rename_table, #requires_reloading?, #shared_cache?, #supports_check_constraints?, #supports_common_table_expressions?, #supports_concurrent_connections?, #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?

Methods included from ArJdbc::Abstract::Core

#initialize, #jdbc_connection

Class Method Details

.database_exists?(config) ⇒ Boolean

Returns:

  • (Boolean)


715
716
717
718
719
720
721
722
723
# File 'lib/arjdbc/sqlite3/adapter.rb', line 715

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



752
753
754
# File 'lib/arjdbc/sqlite3/adapter.rb', line 752

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

.represent_boolean_as_integer=(value) ⇒ Object

:nodoc:



705
706
707
708
709
710
711
712
713
# File 'lib/arjdbc/sqlite3/adapter.rb', line 705

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)


730
731
732
733
734
# File 'lib/arjdbc/sqlite3/adapter.rb', line 730

def begin_isolated_db_transaction(isolation)
  raise ActiveRecord::TransactionIsolationError, "SQLite3 only supports the `read_uncommitted` transaction isolation level" if isolation != :read_uncommitted
  raise StandardError, "You need to enable the shared-cache mode in SQLite mode before attempting to change the transaction isolation level" unless shared_cache?
  super
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



739
740
741
# File 'lib/arjdbc/sqlite3/adapter.rb', line 739

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

#jdbc_column_classObject



743
744
745
# File 'lib/arjdbc/sqlite3/adapter.rb', line 743

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

#jdbc_connection_class(spec) ⇒ Object



747
748
749
# File 'lib/arjdbc/sqlite3/adapter.rb', line 747

def jdbc_connection_class(spec)
  self.class.jdbc_connection_class
end

#supports_transaction_isolation?Boolean

Returns:

  • (Boolean)


726
727
728
# File 'lib/arjdbc/sqlite3/adapter.rb', line 726

def supports_transaction_isolation?
  false
end