File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Tests/StructuredQueriesTests Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -1153,6 +1153,50 @@ extension SnapshotTests {
11531153 """
11541154 }
11551155 }
1156+
1157+ @Test func optionalMapAndFlatMap( ) {
1158+ do {
1159+ let query : some Statement < Bool ? > = Reminder . select {
1160+ $0. priority. map { $0 < Priority . high }
1161+ }
1162+ assertQuery ( query) {
1163+ """
1164+ SELECT ( " reminders " . " priority " < 3)
1165+ FROM " reminders "
1166+ """
1167+ } results: {
1168+ """
1169+ ┌───────┐
1170+ │ nil │
1171+ │ nil │
1172+ │ false │
1173+ │ nil │
1174+ │ nil │
1175+ │ false │
1176+ │ true │
1177+ │ false │
1178+ │ nil │
1179+ │ true │
1180+ └───────┘
1181+ """
1182+ }
1183+ }
1184+ do {
1185+ let query : some Statement < Int ? > = Reminder . select { $0. priority. flatMap { $0. max ( ) } }
1186+ assertQuery ( query) {
1187+ """
1188+ SELECT max( " reminders " . " priority " )
1189+ FROM " reminders "
1190+ """
1191+ } results: {
1192+ """
1193+ ┌───┐
1194+ │ 3 │
1195+ └───┘
1196+ """
1197+ }
1198+ }
1199+ }
11561200 }
11571201}
11581202
You can’t perform that action at this time.
0 commit comments