Skip to content

Commit

Permalink
Merge pull request #32923 from yahonda/bump_sqlite3_version_to_38
Browse files Browse the repository at this point in the history
Bump minimum SQLite version to 3.8
  • Loading branch information
kamipo committed May 21, 2018
2 parents a77447f + d1a74c1 commit 054893d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 32 deletions.
Expand Up @@ -1062,13 +1062,7 @@ def assume_migrated_upto_version(version, migrations_paths)
if (duplicate = inserting.detect { |v| inserting.count(v) > 1 })
raise "Duplicate migration #{duplicate}. Please renumber your migrations to resolve the conflict."
end
if supports_multi_insert?
execute insert_versions_sql(inserting)
else
inserting.each do |v|
execute insert_versions_sql(v)
end
end
execute insert_versions_sql(inserting)
end
end

Expand Down
Expand Up @@ -137,6 +137,10 @@ def initialize(version_string)
def <=>(version_string)
@version <=> version_string.split(".").map(&:to_i)
end

def to_s
@version.join(".")
end
end

def valid_type?(type) # :nodoc:
Expand Down Expand Up @@ -320,6 +324,7 @@ def supports_comments_in_create?
def supports_multi_insert?
true
end
deprecate :supports_multi_insert?

# Does this adapter support virtual columns?
def supports_virtual_columns?
Expand Down
Expand Up @@ -104,6 +104,10 @@ def initialize(connection, logger, connection_options, config)
@active = true
@statements = StatementPool.new(self.class.type_cast_config_to_integer(config[:statement_limit]))

if sqlite_version < "3.8.0"
raise "Your version of SQLite (#{sqlite_version}) is too old. Active Record supports SQLite >= 3.8."
end

configure_connection
end

Expand All @@ -116,15 +120,15 @@ def supports_savepoints?
end

def supports_partial_index?
sqlite_version >= "3.8.0"
true
end

def requires_reloading?
true
end

def supports_foreign_keys_in_create?
sqlite_version >= "3.6.19"
true
end

def supports_views?
Expand All @@ -139,10 +143,6 @@ def supports_json?
true
end

def supports_multi_insert?
sqlite_version >= "3.7.11"
end

def active?
@active
end
Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/cases/adapter_test.rb
Expand Up @@ -295,6 +295,10 @@ def test_log_invalid_encoding
assert_equal "ы", error.message
end
end

def test_supports_multi_insert_is_deprecated
assert_deprecated { @connection.supports_multi_insert? }
end
end

class AdapterForeignKeyTest < ActiveRecord::TestCase
Expand Down
20 changes: 1 addition & 19 deletions activerecord/test/cases/schema_dumper_test.rb
Expand Up @@ -37,24 +37,6 @@ def test_dump_schema_information_outputs_lexically_ordered_versions
ActiveRecord::SchemaMigration.delete_all
end

if current_adapter?(:SQLite3Adapter)
%w{3.7.8 3.7.11 3.7.12}.each do |version_string|
test "dumps schema version for sqlite version #{version_string}" do
version = ActiveRecord::ConnectionAdapters::SQLite3Adapter::Version.new(version_string)
ActiveRecord::Base.connection.stubs(:sqlite_version).returns(version)

versions = %w{ 20100101010101 20100201010101 20100301010101 }
versions.reverse_each do |v|
ActiveRecord::SchemaMigration.create!(version: v)
end

schema_info = ActiveRecord::Base.connection.dump_schema_information
assert_match(/20100201010101.*20100301010101/m, schema_info)
ActiveRecord::SchemaMigration.delete_all
end
end
end

def test_schema_dump
output = standard_dump
assert_match %r{create_table "accounts"}, output
Expand Down Expand Up @@ -192,7 +174,7 @@ def test_schema_dumps_index_columns_in_right_order

def test_schema_dumps_partial_indices
index_definition = dump_table_schema("companies").split(/\n/).grep(/t\.index.*company_partial_index/).first.strip
if current_adapter?(:PostgreSQLAdapter, :SQLite3Adapter) && ActiveRecord::Base.connection.supports_partial_index?
if ActiveRecord::Base.connection.supports_partial_index?
assert_equal 't.index ["firm_id", "type"], name: "company_partial_index", where: "(rating > 10)"', index_definition
else
assert_equal 't.index ["firm_id", "type"], name: "company_partial_index"', index_definition
Expand Down

0 comments on commit 054893d

Please sign in to comment.