Skip to content

Commit 8342b1a

Browse files
authored
Rename 'name' to 'title'. (#25)
1 parent b3e18c5 commit 8342b1a

File tree

11 files changed

+353
-358
lines changed

11 files changed

+353
-358
lines changed

Tests/StructuredQueriesTests/AggregateFunctionsTests.swift

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ extension SnapshotTests {
247247
"""
248248
}
249249

250-
assertQuery(Tag.select { $0.name.groupConcat() }.order(by: \.name)) {
250+
assertQuery(Tag.select { $0.title.groupConcat() }.order(by: \.title)) {
251251
"""
252-
SELECT group_concat("tags"."name")
252+
SELECT group_concat("tags"."title")
253253
FROM "tags"
254-
ORDER BY "tags"."name"
254+
ORDER BY "tags"."title"
255255
"""
256-
} results: {
256+
}results: {
257257
"""
258258
┌─────────────────────────────┐
259259
"car,kids,someday,optional"
@@ -263,16 +263,16 @@ extension SnapshotTests {
263263
assertQuery(
264264
Tag
265265
.select {
266-
#sql("iif(\($0.name.length() > 5), \($0.name), NULL)", as: String?.self).groupConcat()
266+
#sql("iif(\($0.title.length() > 5), \($0.title), NULL)", as: String?.self).groupConcat()
267267
}
268-
.order(by: \.name)
268+
.order(by: \.title)
269269
) {
270270
"""
271-
SELECT group_concat(iif((length("tags"."name") > 5), "tags"."name", NULL))
271+
SELECT group_concat(iif((length("tags"."title") > 5), "tags"."title", NULL))
272272
FROM "tags"
273-
ORDER BY "tags"."name"
273+
ORDER BY "tags"."title"
274274
"""
275-
} results: {
275+
}results: {
276276
"""
277277
┌────────────────────┐
278278
"someday,optional"
@@ -283,17 +283,17 @@ extension SnapshotTests {
283283
Tag
284284
.select {
285285
Case()
286-
.when($0.name.length() > 5, then: $0.name)
286+
.when($0.title.length() > 5, then: $0.title)
287287
.groupConcat()
288288
}
289-
.order(by: \.name)
289+
.order(by: \.title)
290290
) {
291291
"""
292-
SELECT group_concat(CASE WHEN (length("tags"."name") > 5) THEN "tags"."name" END)
292+
SELECT group_concat(CASE WHEN (length("tags"."title") > 5) THEN "tags"."title" END)
293293
FROM "tags"
294-
ORDER BY "tags"."name"
294+
ORDER BY "tags"."title"
295295
"""
296-
} results: {
296+
}results: {
297297
"""
298298
┌────────────────────┐
299299
"someday,optional"
@@ -304,18 +304,18 @@ extension SnapshotTests {
304304
assertQuery(
305305
Tag
306306
.select {
307-
Case($0.name.length())
308-
.when(7, then: $0.name)
307+
Case($0.title.length())
308+
.when(7, then: $0.title)
309309
.groupConcat()
310310
}
311-
.order(by: \.name)
311+
.order(by: \.title)
312312
) {
313313
"""
314-
SELECT group_concat(CASE length("tags"."name") WHEN 7 THEN "tags"."name" END)
314+
SELECT group_concat(CASE length("tags"."title") WHEN 7 THEN "tags"."title" END)
315315
FROM "tags"
316-
ORDER BY "tags"."name"
316+
ORDER BY "tags"."title"
317317
"""
318-
} results: {
318+
}results: {
319319
"""
320320
┌───────────┐
321321
"someday"
@@ -349,12 +349,12 @@ extension SnapshotTests {
349349
└───┘
350350
"""
351351
}
352-
assertQuery(Tag.select { ($0.name + "!").groupConcat(", ") }) {
352+
assertQuery(Tag.select { ($0.title + "!").groupConcat(", ") }) {
353353
"""
354-
SELECT group_concat(("tags"."name" || '!'), ', ')
354+
SELECT group_concat(("tags"."title" || '!'), ', ')
355355
FROM "tags"
356356
"""
357-
} results: {
357+
}results: {
358358
"""
359359
┌────────────────────────────────────┐
360360
"car!, kids!, someday!, optional!"

Tests/StructuredQueriesTests/DeleteTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,17 @@ extension SnapshotTests {
135135
"""
136136
DELETE FROM "remindersLists" AS "rs"
137137
WHERE ("rs"."id" = 1)
138-
RETURNING "id", "color", "name"
138+
RETURNING "id", "color", "title"
139139
"""
140-
} results: {
140+
}results: {
141141
"""
142-
┌────────────────────┐
143-
│ RemindersList( │
144-
│ id: 1, │
145-
│ color: 4889071, │
146-
name: "Personal"
147-
│ ) │
148-
└────────────────────┘
142+
┌────────────────────
143+
│ RemindersList(
144+
│ id: 1,
145+
│ color: 4889071,
146+
title: "Personal"
147+
│ )
148+
└────────────────────
149149
"""
150150
}
151151
}

Tests/StructuredQueriesTests/InsertTests.swift

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -194,37 +194,37 @@ extension SnapshotTests {
194194
@Test func select() {
195195
assertQuery(
196196
Tag.insert {
197-
$0.name
197+
$0.title
198198
} select: {
199-
RemindersList.select { $0.name.lower() }
199+
RemindersList.select { $0.title.lower() }
200200
}
201201
.returning(\.self)
202202
) {
203203
"""
204204
INSERT INTO "tags"
205-
("name")
206-
SELECT lower("remindersLists"."name")
205+
("title")
206+
SELECT lower("remindersLists"."title")
207207
FROM "remindersLists"
208-
RETURNING "id", "name"
209-
"""
210-
} results: {
211-
"""
212-
┌────────────────────┐
213-
│ Tag( │
214-
│ id: 5, │
215-
name: "business"
216-
│ ) │
217-
├────────────────────┤
218-
│ Tag( │
219-
│ id: 6, │
220-
name: "family"
221-
│ ) │
222-
├────────────────────┤
223-
│ Tag( │
224-
│ id: 7, │
225-
name: "personal"
226-
│ ) │
227-
└────────────────────┘
208+
RETURNING "id", "title"
209+
"""
210+
}results: {
211+
"""
212+
┌────────────────────
213+
│ Tag(
214+
│ id: 5,
215+
title: "business"
216+
│ )
217+
├────────────────────
218+
│ Tag(
219+
│ id: 6,
220+
title: "family"
221+
│ )
222+
├────────────────────
223+
│ Tag(
224+
│ id: 7,
225+
title: "personal"
226+
│ )
227+
└────────────────────
228228
"""
229229
}
230230
}
@@ -400,20 +400,20 @@ extension SnapshotTests {
400400

401401
@Test func upsertWithoutID_OtherConflict() {
402402
assertQuery(
403-
RemindersList.upsert(RemindersList.Draft(name: "Personal"))
403+
RemindersList.upsert(RemindersList.Draft(title: "Personal"))
404404
.returning(\.self)
405405
) {
406406
"""
407407
INSERT INTO "remindersLists"
408-
("id", "color", "name")
408+
("id", "color", "title")
409409
VALUES
410410
(NULL, 4889071, 'Personal')
411-
ON CONFLICT ("id") DO UPDATE SET "color" = "excluded"."color", "name" = "excluded"."name"
412-
RETURNING "id", "color", "name"
411+
ON CONFLICT ("id") DO UPDATE SET "color" = "excluded"."color", "title" = "excluded"."title"
412+
RETURNING "id", "color", "title"
413413
"""
414-
} results: {
414+
}results: {
415415
"""
416-
UNIQUE constraint failed: remindersLists.name
416+
UNIQUE constraint failed: remindersLists.title
417417
"""
418418
}
419419
}
@@ -432,16 +432,11 @@ extension SnapshotTests {
432432
"""
433433
INSERT INTO "tags" ("name")
434434
VALUES ('office')
435-
RETURNING "tags"."id", "tags"."name"
435+
RETURNING "tags"."id", "tags"."title"
436436
"""
437-
} results: {
437+
}results: {
438438
"""
439-
┌──────────────────┐
440-
│ Tag( │
441-
│ id: 5, │
442-
│ name: "office"
443-
│ ) │
444-
└──────────────────┘
439+
table tags has no column named name
445440
"""
446441
}
447442
}
@@ -450,26 +445,26 @@ extension SnapshotTests {
450445
enum R: AliasName {}
451446
assertQuery(
452447
RemindersList.as(R.self).insert {
453-
$0.name
448+
$0.title
454449
} values: {
455450
"cruise"
456451
}
457452
.returning(\.self)
458453
) {
459454
"""
460455
INSERT INTO "remindersLists" AS "rs"
461-
("name")
456+
("title")
462457
VALUES
463458
('cruise')
464-
RETURNING "id", "color", "name"
459+
RETURNING "id", "color", "title"
465460
"""
466-
} results: {
461+
}results: {
467462
"""
468463
┌───────────────────┐
469464
│ RemindersList( │
470465
│ id: 4, │
471466
│ color: 4889071, │
472-
name: "cruise"
467+
title: "cruise"
473468
│ ) │
474469
└───────────────────┘
475470
"""

Tests/StructuredQueriesTests/JoinTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ extension SnapshotTests {
1010
Reminder
1111
.order { $0.dueDate.desc() }
1212
.join(RemindersList.all) { $0.remindersListID.eq($1.id) }
13-
.select { ($0.title, $1.name) }
13+
.select { ($0.title, $1.title) }
1414
) {
1515
"""
16-
SELECT "reminders"."title", "remindersLists"."name"
16+
SELECT "reminders"."title", "remindersLists"."title"
1717
FROM "reminders"
1818
JOIN "remindersLists" ON ("reminders"."remindersListID" = "remindersLists"."id")
1919
ORDER BY "reminders"."dueDate" DESC
2020
"""
21-
} results: {
21+
}results: {
2222
"""
2323
┌────────────────────────────┬────────────┐
2424
"Take out trash""Family"

Tests/StructuredQueriesTests/LiveTests.swift

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -184,32 +184,32 @@ extension SnapshotTests {
184184
.select { ($0, $1.id.count()) }
185185
) {
186186
"""
187-
SELECT "remindersLists"."id", "remindersLists"."color", "remindersLists"."name", count("reminders"."id")
187+
SELECT "remindersLists"."id", "remindersLists"."color", "remindersLists"."title", count("reminders"."id")
188188
FROM "remindersLists"
189189
JOIN "reminders" ON ("remindersLists"."id" = "reminders"."remindersListID")
190190
GROUP BY "remindersLists"."id"
191191
"""
192-
} results: {
192+
}results: {
193193
"""
194-
┌────────────────────┬───┐
195-
│ RemindersList( │ 5 │
196-
│ id: 1, │ │
197-
│ color: 4889071, │ │
198-
name: "Personal" │ │
199-
│ ) │ │
200-
├────────────────────┼───┤
201-
│ RemindersList( │ 3 │
202-
│ id: 2, │ │
203-
│ color: 15567157, │ │
204-
name: "Family" │ │
205-
│ ) │ │
206-
├────────────────────┼───┤
207-
│ RemindersList( │ 2 │
208-
│ id: 3, │ │
209-
│ color: 11689427, │ │
210-
name: "Business" │ │
211-
│ ) │ │
212-
└────────────────────┴───┘
194+
┌────────────────────┬───┐
195+
│ RemindersList( │ 5 │
196+
│ id: 1, │ │
197+
│ color: 4889071, │ │
198+
title: "Personal" │ │
199+
│ ) │ │
200+
├────────────────────┼───┤
201+
│ RemindersList( │ 3 │
202+
│ id: 2, │ │
203+
│ color: 15567157, │ │
204+
title: "Family" │ │
205+
│ ) │ │
206+
├────────────────────┼───┤
207+
│ RemindersList( │ 2 │
208+
│ id: 3, │ │
209+
│ color: 11689427, │ │
210+
title: "Business" │ │
211+
│ ) │ │
212+
└────────────────────┴───┘
213213
"""
214214
}
215215
}
@@ -220,16 +220,16 @@ extension SnapshotTests {
220220
.group(by: \.id)
221221
.join(ReminderTag.all) { $0.id.eq($1.reminderID) }
222222
.join(Tag.all) { $1.tagID.eq($2.id) }
223-
.select { ($0, $2.name.groupConcat()) }
223+
.select { ($0, $2.title.groupConcat()) }
224224
) {
225225
"""
226-
SELECT "reminders"."id", "reminders"."assignedUserID", "reminders"."dueDate", "reminders"."isCompleted", "reminders"."isFlagged", "reminders"."notes", "reminders"."priority", "reminders"."remindersListID", "reminders"."title", group_concat("tags"."name")
226+
SELECT "reminders"."id", "reminders"."assignedUserID", "reminders"."dueDate", "reminders"."isCompleted", "reminders"."isFlagged", "reminders"."notes", "reminders"."priority", "reminders"."remindersListID", "reminders"."title", group_concat("tags"."title")
227227
FROM "reminders"
228-
JOIN "reminderTags" ON ("reminders"."id" = "reminderTags"."reminderID")
229-
JOIN "tags" ON ("reminderTags"."tagID" = "tags"."id")
228+
JOIN "remindersTags" ON ("reminders"."id" = "remindersTags"."reminderID")
229+
JOIN "tags" ON ("remindersTags"."tagID" = "tags"."id")
230230
GROUP BY "reminders"."id"
231231
"""
232-
} results: {
232+
}results: {
233233
"""
234234
┌────────────────────────────────────────────┬────────────────────┐
235235
│ Reminder( │ "someday,optional"

Tests/StructuredQueriesTests/PrimaryKeyedTableTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,16 @@ extension SnapshotTests {
132132
assertQuery(
133133
Reminder
134134
.join(RemindersList.all) { $0.remindersListID == $1.id }
135-
.select { ($0.title, $1.name) }
135+
.select { ($0.title, $1.title) }
136136
.find(2)
137137
) {
138138
"""
139-
SELECT "reminders"."title", "remindersLists"."name"
139+
SELECT "reminders"."title", "remindersLists"."title"
140140
FROM "reminders"
141141
JOIN "remindersLists" ON ("reminders"."remindersListID" = "remindersLists"."id")
142142
WHERE ("reminders"."id" = 2)
143143
"""
144-
} results: {
144+
}results: {
145145
"""
146146
┌───────────┬────────────┐
147147
"Haircut""Personal"

0 commit comments

Comments
 (0)