Skip to content

Commit b9e84f4

Browse files
authored
Merge pull request #1057 from dr-itz/rails61-dev
Rails 6.1 fixes
2 parents 9024932 + 0988d7e commit b9e84f4

File tree

5 files changed

+36
-4
lines changed

5 files changed

+36
-4
lines changed

lib/arjdbc/postgresql/adapter.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ def supports_partial_index?
213213
true
214214
end
215215

216+
def supports_partitioned_indexes?
217+
database_version >= 110_000
218+
end
219+
216220
def supports_expression_index?
217221
true
218222
end
@@ -437,6 +441,7 @@ def build_insert_sql(insert) # :nodoc:
437441
sql << " ON CONFLICT #{insert.conflict_target} DO NOTHING"
438442
elsif insert.update_duplicates?
439443
sql << " ON CONFLICT #{insert.conflict_target} DO UPDATE SET "
444+
sql << insert.touch_model_timestamps_unless { |column| "#{insert.model.quoted_table_name}.#{column} IS NOT DISTINCT FROM excluded.#{column}" }
440445
sql << insert.updatable_columns.map { |column| "#{column}=excluded.#{column}" }.join(",")
441446
end
442447

lib/arjdbc/sqlite3/adapter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ def build_insert_sql(insert) # :nodoc:
346346
sql << " ON CONFLICT #{insert.conflict_target} DO NOTHING"
347347
elsif insert.update_duplicates?
348348
sql << " ON CONFLICT #{insert.conflict_target} DO UPDATE SET "
349+
sql << insert.touch_model_timestamps_unless { |column| "#{column} IS excluded.#{column}" }
349350
sql << insert.updatable_columns.map { |column| "#{column}=excluded.#{column}" }.join(",")
350351
end
351352

lib/arjdbc/tasks/databases.rake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ module ActiveRecord::Tasks
55
DatabaseTasks.module_eval do
66

77
# @override patched to adapt jdbc configuration
8-
def each_current_configuration(environment, spec_name = nil)
8+
def each_current_configuration(environment, name = nil)
99
environments = [environment]
1010
environments << 'test' if environment == 'development'
1111

1212
environments.each do |env|
1313
ActiveRecord::Base.configurations.configs_for(env_name: env).each do |db_config|
14-
next if spec_name && spec_name != db_config.spec_name
14+
next if name && name != db_config.name
1515

1616
if db_config.database
17-
yield adapt_jdbc_config(db_config), db_config.spec_name, env
17+
yield adapt_jdbc_config(db_config), db_config.name, env
1818
end
1919
end
2020
end
@@ -38,7 +38,7 @@ module ActiveRecord::Tasks
3838
def adapt_jdbc_config(db_config)
3939
if db_config.adapter.start_with? 'jdbc'
4040
config = db_config.configuration_hash.merge(adapter: db_config.adapter.sub(/^jdbc/, ''))
41-
db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(db_config.env_name, db_config.spec_name, config)
41+
db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(db_config.env_name, db_config.name, config)
4242
end
4343
db_config
4444
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# These tests all try various multi-DB things, using an SQLite3 database. When
3+
# running the Rails tests from AR-JDBC, the SQLite3 JARs are not on the search
4+
# path so this fails.
5+
#
6+
exclude :test_establish_connection_using_3_levels_config, 'tries to load SQLite3 driver'
7+
exclude :test_establish_connection_using_3_levels_config_with_shards_and_replica, 'tries to load SQLite3 driver'
8+
exclude :test_switching_connections_via_handler, 'tries to load SQLite3 driver'
9+
exclude :test_retrieves_proper_connection_with_nested_connected_to, 'tries to load SQLite3 driver'
10+
exclude :test_same_shards_across_clusters, 'tries to load SQLite3 driver'
11+
exclude :test_sharding_separation, 'tries to load SQLite3 driver'
12+
exclude :test_swapping_shards_in_a_multi_threaded_environment, 'tries to load SQLite3 driver'
13+
exclude :test_swapping_shards_and_roles_in_a_multi_threaded_environment, 'tries to load SQLite3 driver'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# These tests all try various multi-DB things, using an SQLite3 database. When
3+
# running the Rails tests from AR-JDBC, the SQLite3 JARs are not on the search
4+
# path so this fails.
5+
#
6+
exclude :test_establish_connection_using_3_levels_config, 'tries to load SQLite3 driver'
7+
exclude :test_establish_connection_using_3_levels_config_with_shards_and_replica, 'tries to load SQLite3 driver'
8+
exclude :test_switching_connections_via_handler, 'tries to load SQLite3 driver'
9+
exclude :test_retrieves_proper_connection_with_nested_connected_to, 'tries to load SQLite3 driver'
10+
exclude :test_same_shards_across_clusters, 'tries to load SQLite3 driver'
11+
exclude :test_sharding_separation, 'tries to load SQLite3 driver'
12+
exclude :test_swapping_shards_in_a_multi_threaded_environment, 'tries to load SQLite3 driver'
13+
exclude :test_swapping_shards_and_roles_in_a_multi_threaded_environment, 'tries to load SQLite3 driver'

0 commit comments

Comments
 (0)