Skip to content

Commit bdef074

Browse files
Test cleanup
Remove unnecessary duplication Remove some lines added during debugging
1 parent cf3da57 commit bdef074

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

test/cases/coerced_tests.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,33 +285,35 @@ def assert_bind_params_to_sql_coerced(prepared:)
285285

286286
# prepared_statements: true
287287
#
288+
# SQL to database:
288289
# EXEC sp_executesql N'SELECT [authors].* FROM [authors] WHERE [authors].[id] IN (@0, @1, @2) OR [authors].[id] IS NULL)', N'@0 bigint, @1 bigint, @2 bigint', @0 = 1, @1 = 2, @2 = 3
289290
#
290291
# prepared_statements: false
291292
#
293+
# SQL to database:
292294
# SELECT [authors].* FROM [authors] WHERE ([authors].[id] IN (1, 2, 3) OR [authors].[id] IS NULL)
293295
#
294-
sql_unprepared = "SELECT #{table}.* FROM #{table} WHERE (#{pk} IN (#{bind_params(1..3)}) OR #{pk} IS NULL)"
295-
sql_prepared = "SELECT #{table}.* FROM #{table} WHERE (#{pk} IN (#{bind_params(1..3)}) OR #{pk} IS NULL)"
296+
expected_logged_sql = "SELECT #{table}.* FROM #{table} WHERE (#{pk} IN (#{bind_params(1..3)}) OR #{pk} IS NULL)"
296297

297298
authors = Author.where(id: [1, 2, 3, nil])
298-
assert_equal sql_unprepared, @connection.to_sql(authors.arel)
299-
assert_queries_match(prepared ? sql_prepared : sql_unprepared) { assert_equal 3, authors.length }
299+
assert_equal expected_logged_sql, @connection.to_sql(authors.arel)
300+
assert_queries_match(expected_logged_sql) { assert_equal 3, authors.length }
300301

301302
# prepared_statements: true
302303
#
304+
# SQL to database:
303305
# EXEC sp_executesql N'SELECT [authors].* FROM [authors] WHERE [authors].[id] IN (@0, @1, @2)', N'@0 bigint, @1 bigint, @2 bigint', @0 = 1, @1 = 2, @2 = 3
304306
#
305307
# prepared_statements: false
306308
#
309+
# SQL to database:
307310
# SELECT [authors].* FROM [authors] WHERE [authors].[id] IN (1, 2, 3)
308311
#
309-
sql_unprepared = "SELECT #{table}.* FROM #{table} WHERE #{pk} IN (#{bind_params(1..3)})"
310-
sql_prepared = "SELECT #{table}.* FROM #{table} WHERE #{pk} IN (#{bind_params(1..3)})"
312+
expected_logged_sql = "SELECT #{table}.* FROM #{table} WHERE #{pk} IN (#{bind_params(1..3)})"
311313

312314
authors = Author.where(id: [1, 2, 3, 9223372036854775808])
313-
assert_equal sql_unprepared, @connection.to_sql(authors.arel)
314-
assert_queries_match(prepared ? sql_prepared : sql_unprepared) { assert_equal 3, authors.length }
315+
assert_equal expected_logged_sql, @connection.to_sql(authors.arel)
316+
assert_queries_match(expected_logged_sql) { assert_equal 3, authors.length }
315317
end
316318
end
317319
end

test/cases/specific_schema_test_sqlserver.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,9 @@ def quoted_id
115115
"'T'"
116116
end
117117
end
118-
value = value.new
119118
# Using ActiveRecord's quoted_id feature for objects.
120-
assert_queries_and_values_match(/.*/, ["'T'", 1]) { SSTestDatatypeMigration.where(char_col: value).first }
121-
assert_queries_and_values_match(/.*/, ["'T'", 1]) { SSTestDatatypeMigration.where(varchar_col: value).first }
119+
assert_queries_and_values_match(/.*/, ["'T'", 1]) { SSTestDatatypeMigration.where(char_col: value.new).first }
120+
assert_queries_and_values_match(/.*/, ["'T'", 1]) { SSTestDatatypeMigration.where(varchar_col: value.new).first }
122121
# Using our custom char type data.
123122
type = ActiveRecord::Type::SQLServer::Char
124123
data = ActiveRecord::Type::SQLServer::Data

0 commit comments

Comments
 (0)