Merge pull request #51072 from eileencodes/raise-error-for-trilogy-and-prepared-statements

Raise error for Trilogy when `prepared_statements` is `true`
This commit is contained in:
Eileen M. Uchitelle 2024-02-13 15:08:58 -05:00 committed by GitHub
commit 8e20f5d3b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View File

@ -83,6 +83,10 @@ module ActiveRecord
# matched rather than number of rows updated.
config[:found_rows] = true
if config[:prepared_statements]
raise ArgumentError, "Trilogy currently doesn't support prepared statements. Remove `prepared_statements: true` from your database configuration."
end
super
end

View File

@ -158,7 +158,7 @@ module ActiveRecord
end
end
unless in_memory_db?
unless in_memory_db? || current_adapter?(:TrilogyAdapter)
def test_disable_prepared_statements
original_prepared_statements = ActiveRecord.disable_prepared_statements
db_config = ActiveRecord::Base.configurations.configs_for(env_name: "arunit", name: "primary")

View File

@ -390,6 +390,12 @@ class TrilogyAdapterTest < ActiveRecord::TrilogyTestCase
end
end
test "setting prepared_statements to true raises" do
assert_raises ArgumentError do
ActiveRecord::ConnectionAdapters::TrilogyAdapter.new(prepared_statements: true).connect!
end
end
# Create a temporary subscription to verify notification is sent.
# Optionally verify the notification payload includes expected types.
def assert_notification(notification, expected_payload = {}, &block)