You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -214,7 +312,7 @@ class BulkInsertWorkerTest < ActiveSupport::TestCase
214
312
end
215
313
216
314
test"adapter dependent default methods"do
217
-
assert_equal@insert.adapter_name,'SQLite'
315
+
assert_equal@insert.adapter_name,'PostgreSQL'
218
316
assert_equal@insert.insert_sql_statement,"INSERT INTO \"testings\" (\"greeting\",\"age\",\"happy\",\"created_at\",\"updated_at\",\"color\") VALUES "
219
317
220
318
@insert.add["Yo",15,false,nil,nil]
@@ -225,6 +323,7 @@ class BulkInsertWorkerTest < ActiveSupport::TestCase
225
323
mysql_worker=BulkInsert::Worker.new(
226
324
Testing.connection,
227
325
Testing.table_name,
326
+
'id',
228
327
%w(greetingagehappycreated_atupdated_atcolor),
229
328
500,# batch size
230
329
true)# ignore
@@ -244,6 +343,7 @@ class BulkInsertWorkerTest < ActiveSupport::TestCase
244
343
mysql_worker=BulkInsert::Worker.new(
245
344
Testing.connection,
246
345
Testing.table_name,
346
+
'id',
247
347
%w(greetingagehappycreated_atupdated_atcolor),
248
348
500,# batch size
249
349
true,# ignore
@@ -262,6 +362,7 @@ class BulkInsertWorkerTest < ActiveSupport::TestCase
262
362
mysql_worker=BulkInsert::Worker.new(
263
363
Testing.connection,
264
364
Testing.table_name,
365
+
'id',
265
366
%w(greetingagehappycreated_atupdated_atcolor),
266
367
500,# batch size
267
368
true)# ignore
@@ -278,32 +379,41 @@ class BulkInsertWorkerTest < ActiveSupport::TestCase
278
379
pgsql_worker=BulkInsert::Worker.new(
279
380
Testing.connection,
280
381
Testing.table_name,
382
+
'id',
281
383
%w(greetingagehappycreated_atupdated_atcolor),
282
384
500,# batch size
283
-
true)# ignore
385
+
true,# ignore
386
+
false,# update duplicates
387
+
true# return primary key
388
+
)
284
389
pgsql_worker.adapter_name='PostgreSQL'
285
390
pgsql_worker.add["Yo",15,false,nil,nil]
286
391
287
-
assert_equalpgsql_worker.compose_insert_query,"INSERT INTO \"testings\" (\"greeting\",\"age\",\"happy\",\"created_at\",\"updated_at\",\"color\") VALUES ('Yo',15,'f',NULL,NULL,'chartreuse') ON CONFLICT DO NOTHING"
392
+
assert_equalpgsql_worker.compose_insert_query,"INSERT INTO \"testings\" (\"greeting\",\"age\",\"happy\",\"created_at\",\"updated_at\",\"color\") VALUES ('Yo',15,'f',NULL,NULL,'chartreuse') ON CONFLICT DO NOTHING RETURNING id"
288
393
end
289
394
290
395
test"adapter dependent PostGIS methods"do
291
396
pgsql_worker=BulkInsert::Worker.new(
292
397
Testing.connection,
293
398
Testing.table_name,
399
+
'id',
294
400
%w(greetingagehappycreated_atupdated_atcolor),
295
401
500,# batch size
296
-
true)# ignore
402
+
true,# ignore
403
+
false,# update duplicates
404
+
true# return primary key
405
+
)# ignore
297
406
pgsql_worker.adapter_name='PostGIS'
298
407
pgsql_worker.add["Yo",15,false,nil,nil]
299
408
300
-
assert_equalpgsql_worker.compose_insert_query,"INSERT INTO \"testings\" (\"greeting\",\"age\",\"happy\",\"created_at\",\"updated_at\",\"color\") VALUES ('Yo',15,'f',NULL,NULL,'chartreuse') ON CONFLICT DO NOTHING"
409
+
assert_equalpgsql_worker.compose_insert_query,"INSERT INTO \"testings\" (\"greeting\",\"age\",\"happy\",\"created_at\",\"updated_at\",\"color\") VALUES ('Yo',15,'f',NULL,NULL,'chartreuse') ON CONFLICT DO NOTHING RETURNING id"
0 commit comments