Skip to content

Commit 9e35025

Browse files
committed
Sync more SQLite adapter code from AR to fix tests
1 parent c4bbbe2 commit 9e35025

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

lib/arjdbc/sqlite3/adapter.rb

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,6 @@ def disable_referential_integrity # :nodoc:
230230
end
231231
end
232232

233-
def all_foreign_keys_valid? # :nodoc:
234-
# Rails 7
235-
check_all_foreign_keys_valid!
236-
true
237-
rescue ActiveRecord::StatementInvalid
238-
false
239-
end
240-
241233
def check_all_foreign_keys_valid! # :nodoc:
242234
# Rails 7.1
243235
sql = "PRAGMA foreign_key_check"
@@ -269,7 +261,8 @@ def remove_index(table_name, column_name = nil, **options) # :nodoc:
269261
#
270262
# Example:
271263
# rename_table('octopuses', 'octopi')
272-
def rename_table(table_name, new_name)
264+
def rename_table(table_name, new_name, **options)
265+
validate_table_length!(new_name) unless options[:_uses_legacy_table_name]
273266
schema_cache.clear_data_source_cache!(table_name.to_s)
274267
schema_cache.clear_data_source_cache!(new_name.to_s)
275268
internal_exec_query "ALTER TABLE #{quote_table_name(table_name)} RENAME TO #{quote_table_name(new_name)}"
@@ -312,6 +305,8 @@ def change_column_default(table_name, column_name, default_or_changes) #:nodoc:
312305
end
313306

314307
def change_column_null(table_name, column_name, null, default = nil) #:nodoc:
308+
validate_change_column_null_argument!(null)
309+
315310
unless null || default.nil?
316311
internal_exec_query("UPDATE #{quote_table_name(table_name)} SET #{quote_column_name(column_name)}=#{quote(default)} WHERE #{quote_column_name(column_name)} IS NULL")
317312
end
@@ -720,6 +715,16 @@ class SQLite3Adapter < AbstractAdapter
720715
include ArJdbc::Abstract::StatementCache
721716
include ArJdbc::Abstract::TransactionSupport
722717

718+
##
719+
# :singleton-method:
720+
# Configure the SQLite3Adapter to be used in a strict strings mode.
721+
# This will disable double-quoted string literals, because otherwise typos can silently go unnoticed.
722+
# For example, it is possible to create an index for a non existing column.
723+
# If you wish to enable this mode you can add the following line to your application.rb file:
724+
#
725+
# config.active_record.sqlite3_adapter_strict_strings_by_default = true
726+
class_attribute :strict_strings_by_default, default: false # Does not actually do anything right now
727+
723728
def self.represent_boolean_as_integer=(value) # :nodoc:
724729
if value == false
725730
raise "`.represent_boolean_as_integer=` is now always true, so make sure your application can work with it and remove this settings."

0 commit comments

Comments
 (0)