@@ -267,7 +267,7 @@ extension SnapshotTests {
267267 as: . sql
268268 ) {
269269 """
270-
270+
271271 """
272272 }
273273 }
@@ -303,7 +303,7 @@ extension SnapshotTests {
303303
304304 @Test func complexMutation( ) {
305305 let updateQuery =
306- Reminder
306+ Reminder
307307 . find ( 1 )
308308 . update {
309309 $0. dueDate = Case ( )
@@ -352,7 +352,58 @@ extension SnapshotTests {
352352 Reminder . none. update { $0. isCompleted. toggle ( ) }
353353 ) {
354354 """
355+
356+ """
357+ }
358+ }
359+ }
360+
361+ @Suite struct SelectionUpdateTests {
362+ @Dependency ( \. defaultDatabase) var db
355363
364+ @Test func setSelectionFields( ) {
365+ let honestValue : Int = 1
366+ let optionalValue : Int ? = 1
367+ assertInlineSnapshot (
368+ of: Root . update {
369+ $0. fields. honestCount = honestValue
370+ //$0.fields.optionalCount = honestValue
371+ $0. fields. optionalCount = optionalValue
372+ } ,
373+ as: . sql
374+ ) {
375+ """
376+ UPDATE " roots "
377+ SET " honestCount " = 1, " optionalCount " = 1
378+ """
379+ }
380+ }
381+
382+ @Test func setSelectionValue( ) {
383+ assertInlineSnapshot (
384+ of: Root . update {
385+ $0. fields = NestedFields ( honestCount: 1 , optionalCount: 1 )
386+ } ,
387+ as: . sql
388+ ) {
389+ """
390+ UPDATE " roots "
391+ SET " honestCount " = 1, " optionalCount " = 1
392+ """
393+ }
394+ }
395+
396+ @Test func readSelectionFields( ) {
397+ assertInlineSnapshot (
398+ of: Root . update {
399+ $0. fields. optionalCount = $0. fields. optionalCount
400+ $0. fields. honestCount = $0. fields. honestCount
401+ } ,
402+ as: . sql
403+ ) {
404+ """
405+ UPDATE " roots "
406+ SET " optionalCount " = " nestedFieldses " . " optionalCount " , " honestCount " = " nestedFieldses " . " honestCount "
356407 """
357408 }
358409 }
@@ -363,3 +414,12 @@ extension SnapshotTests {
363414 var title = " "
364415 var quantity = 0
365416}
417+
418+ @Table private struct Root {
419+ @Columns var fields : NestedFields
420+ }
421+
422+ @Selection struct NestedFields {
423+ var honestCount : Int = 0
424+ var optionalCount : Int ?
425+ }
0 commit comments