Class: ActiveRecord::ConnectionAdapters::SQLite3Adapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActiveRecord::ConnectionAdapters::SQLite3Adapter
- 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
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
Class Method Summary collapse
- .database_exists?(config) ⇒ Boolean
- .jdbc_connection_class ⇒ Object
-
.represent_boolean_as_integer=(value) ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #begin_isolated_db_transaction(isolation) ⇒ Object
-
#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.
- #jdbc_column_class ⇒ Object
- #jdbc_connection_class(spec) ⇒ Object
- #supports_transaction_isolation? ⇒ Boolean
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, #begin_db_transaction, #build_insert_sql, #build_truncate_statement, #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?, #shared_cache?, #supports_check_constraints?, #supports_common_table_expressions?, #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
675 676 677 678 679 680 681 682 683 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 675 def self.database_exists?(config) config = config.symbolize_keys if config[:database] == ":memory:" return true else database_file = defined?(Rails.root) ? File.(config[:database], Rails.root) : config[:database] File.exist?(database_file) end end |
.jdbc_connection_class ⇒ Object
712 713 714 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 712 def self.jdbc_connection_class ::ActiveRecord::ConnectionAdapters::SQLite3JdbcConnection end |
.represent_boolean_as_integer=(value) ⇒ Object
:nodoc:
665 666 667 668 669 670 671 672 673 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 665 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
690 691 692 693 694 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 690 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
699 700 701 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 699 def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil) exec_query(sql, name, binds) end |
#jdbc_column_class ⇒ Object
703 704 705 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 703 def jdbc_column_class ::ActiveRecord::ConnectionAdapters::SQLite3Column end |
#jdbc_connection_class(spec) ⇒ Object
707 708 709 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 707 def jdbc_connection_class(spec) self.class.jdbc_connection_class end |
#supports_transaction_isolation? ⇒ Boolean
686 687 688 |
# File 'lib/arjdbc/sqlite3/adapter.rb', line 686 def supports_transaction_isolation? false end |