Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions Tests/StructuredQueriesTests/InsertTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,36 @@ extension SnapshotTests {
}
}

@Test func upsertRepresentation() {
assertQuery(
Item.insert {
$0.notes
} values: {
["Hello", "World"]
} onConflictDoUpdate: {
$0.notes = ["Goodnight", "Moon"]
}
) {
"""
INSERT INTO "items"
("notes")
VALUES
('[
"Hello",
"World"
]')
ON CONFLICT DO UPDATE SET "notes" = '[
"Goodnight",
"Moon"
]'
"""
} results: {
"""
no such table: items
"""
}
}

@Test func sql() {
assertQuery(
#sql(
Expand Down Expand Up @@ -537,9 +567,11 @@ extension SnapshotTests {
) {
"""
INSERT INTO "items"
("title", "quantity")
("title", "quantity", "notes")
VALUES
('', 0)
('', 0, '[

]')
"""
}
}
Expand Down Expand Up @@ -642,4 +674,6 @@ extension SnapshotTests {
@Table private struct Item {
var title = ""
var quantity = 0
@Column(as: [String].JSONRepresentation.self)
var notes: [String] = []
}