@ -52,14 +52,16 @@ public extension QueryInterfaceRequest where RowDecoder: FetchableRecord & Table
@ discardableResult
func updateAllAndConfig (
_ db : Database ,
calledFromConfig : Bool = false ,
_ assignments : ConfigColumnAssignment . . .
) throws -> Int {
return try updateAllAndConfig ( db , assignments)
return try updateAllAndConfig ( db , calledFromConfig: calledFromConfig , assignments)
}
@ discardableResult
func updateAllAndConfig (
_ db : Database ,
calledFromConfig : Bool = false ,
_ assignments : [ ConfigColumnAssignment ]
) throws -> Int {
let targetAssignments : [ ColumnAssignment ] = assignments . map { $0 . assignment }
@ -69,7 +71,7 @@ public extension QueryInterfaceRequest where RowDecoder: FetchableRecord & Table
return try self . updateAll ( db , targetAssignments )
}
return try self . updateAndFetchAllAndUpdateConfig ( db , assignments) . count
return try self . updateAndFetchAllAndUpdateConfig ( db , calledFromConfig: calledFromConfig , assignments) . count
}
// MARK: - - u p d a t e A n d F e t c h A l l
@ -77,21 +79,26 @@ public extension QueryInterfaceRequest where RowDecoder: FetchableRecord & Table
@ discardableResult
func updateAndFetchAllAndUpdateConfig (
_ db : Database ,
calledFromConfig : Bool = false ,
_ assignments : ConfigColumnAssignment . . .
) throws -> [ RowDecoder ] {
return try updateAndFetchAllAndUpdateConfig ( db , assignments)
return try updateAndFetchAllAndUpdateConfig ( db , calledFromConfig: calledFromConfig , assignments)
}
@ discardableResult
func updateAndFetchAllAndUpdateConfig (
_ db : Database ,
calledFromConfig : Bool = false ,
_ assignments : [ ConfigColumnAssignment ]
) throws -> [ RowDecoder ] {
// F i r s t p e r f o r m t h e a c t u a l u p d a t e s
let updatedData : [ RowDecoder ] = try self . updateAndFetchAll ( db , assignments . map { $0 . assignment } )
// T h e n c h e c k i f a n y o f t h e c h a n g e s c o u l d a f f e c t t h e c o n f i g
guard SessionUtil . assignmentsRequireConfigUpdate ( assignments ) else { return updatedData }
guard
! calledFromConfig &&
SessionUtil . assignmentsRequireConfigUpdate ( assignments )
else { return updatedData }
defer {
// I f w e c h a n g e d a c o l u m n t h a t r e q u i r e s a c o n f i g u p d a t e t h e n w e m a y a s w e l l a u t o m a t i c a l l y