File tree Expand file tree Collapse file tree 1 file changed +36
-2
lines changed
Tests/StructuredQueriesTests Expand file tree Collapse file tree 1 file changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -476,6 +476,36 @@ extension SnapshotTests {
476
476
}
477
477
}
478
478
479
+ @Test func upsertRepresentation( ) {
480
+ assertQuery (
481
+ Item . insert {
482
+ $0. notes
483
+ } values: {
484
+ [ " Hello " , " World " ]
485
+ } onConflictDoUpdate: {
486
+ $0. notes = [ " Goodnight " , " Moon " ]
487
+ }
488
+ ) {
489
+ """
490
+ INSERT INTO " items "
491
+ ( " notes " )
492
+ VALUES
493
+ ('[
494
+ " Hello " ,
495
+ " World "
496
+ ]')
497
+ ON CONFLICT DO UPDATE SET " notes " = '[
498
+ " Goodnight " ,
499
+ " Moon "
500
+ ]'
501
+ """
502
+ } results: {
503
+ """
504
+ no such table: items
505
+ """
506
+ }
507
+ }
508
+
479
509
@Test func sql( ) {
480
510
assertQuery (
481
511
#sql(
@@ -537,9 +567,11 @@ extension SnapshotTests {
537
567
) {
538
568
"""
539
569
INSERT INTO " items "
540
- ( " title " , " quantity " )
570
+ ( " title " , " quantity " , " notes " )
541
571
VALUES
542
- ('', 0)
572
+ ('', 0, '[
573
+
574
+ ]')
543
575
"""
544
576
}
545
577
}
@@ -642,4 +674,6 @@ extension SnapshotTests {
642
674
@Table private struct Item {
643
675
var title = " "
644
676
var quantity = 0
677
+ @Column ( as: [ String ] . JSONRepresentation. self)
678
+ var notes : [ String ] = [ ]
645
679
}
You can’t perform that action at this time.
0 commit comments