Skip to content

Commit ceb40eb

Browse files
committed
wip
1 parent 372a673 commit ceb40eb

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

Tests/StructuredQueriesTests/PrimaryKeyedTableTests.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,28 +186,36 @@ extension SnapshotTests {
186186
}
187187
}
188188

189-
@Test func uuid() throws {
189+
@Test func uuidAndGeneratedColumn() throws {
190190
try database.execute(
191191
#sql(
192192
"""
193-
CREATE TABLE "rows" (id TEXT PRIMARY KEY NOT NULL)
193+
CREATE TABLE "rows" (
194+
"id" TEXT PRIMARY KEY NOT NULL,
195+
"isDeleted" INTEGER NOT NULL DEFAULT 0,
196+
"isNotDeleted" INTEGER NOT NULL AS (NOT "isDeleted")
197+
)
194198
"""
195199
)
196200
)
197-
try database.execute(Row.insert { Row(id: UUID(1)) })
201+
try database.execute(Row.insert { Row.Draft(id: UUID(1)) })
198202
assertQuery(
199203
Row.find(UUID(1))
200204
) {
201205
"""
202-
SELECT "rows"."id"
206+
SELECT "rows"."id", "rows"."isDeleted", "rows"."isNotDeleted"
203207
FROM "rows"
204208
WHERE ("rows"."id" = '00000000-0000-0000-0000-000000000001')
205209
"""
206210
} results: {
207211
"""
208-
┌─────────────────────────────────────────────────────┐
209-
│ Row(id: UUID(00000000-0000-0000-0000-000000000001)) │
210-
└─────────────────────────────────────────────────────┘
212+
┌───────────────────────────────────────────────────┐
213+
│ Row( │
214+
│ id: UUID(00000000-0000-0000-0000-000000000001), │
215+
│ isDeleted: false, │
216+
│ isNotDeleted: true │
217+
│ ) │
218+
└───────────────────────────────────────────────────┘
211219
"""
212220
}
213221
}
@@ -222,4 +230,7 @@ extension SnapshotTests {
222230
@Table
223231
private struct Row {
224232
let id: UUID
233+
var isDeleted = false
234+
@Column(generated: .virtual)
235+
let isNotDeleted: Bool
225236
}

0 commit comments

Comments
 (0)