Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

adapt sql generated expectancies

ulferts49f4c4885f18
diff --git a/spec/support/queries/filters/shared_filter_examples.rb b/spec/support/queries/filters/shared_filter_examples.rb
index a03447c27ea..bf15e63c013 100644
--- a/spec/support/queries/filters/shared_filter_examples.rb
+++ b/spec/support/queries/filters/shared_filter_examples.rb
@@ -163,8 +163,10 @@ RSpec.shared_examples_for "list_optional query filter" do
let(:operator) { "=" }
it "is the same as handwriting the query" do
+ quoted_values = db_values.map { |val| "'#{ActiveRecord::Base.connection.quote_string(val)}'" }.join(",")
+
expected = expected_base_scope
- .where(["#{expected_table_name}.#{attribute} IN (?)", db_values])
+ .where("#{expected_table_name}.#{attribute} IN (#{quoted_values})")
expect(instance.apply_to(model).to_sql).to eql expected.to_sql
end
@@ -174,9 +176,11 @@ RSpec.shared_examples_for "list_optional query filter" do
let(:operator) { "!" }
it "is the same as handwriting the query" do
+ quoted_values = db_values.map { |val| "'#{ActiveRecord::Base.connection.quote_string(val)}'" }.join(",")
+
sql = "(#{expected_table_name}.#{attribute} IS NULL
- OR #{expected_table_name}.#{attribute} NOT IN (?))".squish
- expected = expected_base_scope.where([sql, db_values])
+ OR #{expected_table_name}.#{attribute} NOT IN (#{quoted_values}))".squish
+ expected = expected_base_scope.where(sql)
expect(instance.apply_to(model).to_sql).to eql expected.to_sql
end