File tree Expand file tree Collapse file tree 4 files changed +35
-4
lines changed
Sources/FluentKit/Query/Database Expand file tree Collapse file tree 4 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,15 @@ extension DatabaseQuery.Limit: CustomStringConvertible {
3131 }
3232}
3333
34+ extension DatabaseQuery . Limit {
35+ var describedByLoggingMetadata : Logger . MetadataValue {
36+ switch self {
37+ case . count( let count) : . stringConvertible( count)
38+ default : " custom "
39+ }
40+ }
41+ }
42+
3443extension DatabaseQuery . Offset : CustomStringConvertible {
3544 public var description : String {
3645 switch self {
@@ -41,3 +50,12 @@ extension DatabaseQuery.Offset: CustomStringConvertible {
4150 }
4251 }
4352}
53+
54+ extension DatabaseQuery . Offset {
55+ var describedByLoggingMetadata : Logger . MetadataValue {
56+ switch self {
57+ case . count( let count) : . stringConvertible( count)
58+ default : " custom "
59+ }
60+ }
61+ }
Original file line number Diff line number Diff line change @@ -36,10 +36,23 @@ extension DatabaseQuery.Value: CustomStringConvertible {
3636
3737 var describedByLoggingMetadata : Logger . MetadataValue {
3838 switch self {
39+ case . bind( let encodable) :
40+ // N.B.: `is` is used instead of `as?` here because the latter irreversibly loses the `Sendable`-ness of the value.
41+ if encodable is any CustomStringConvertible {
42+ . stringConvertible( encodable as! any CustomStringConvertible & Sendable )
43+ } else {
44+ . string( String ( describing: encodable) )
45+ }
3946 case . dictionary( let d) :
4047 . dictionary( . init( uniqueKeysWithValues: d. map { ( $0. description, $1. describedByLoggingMetadata) } ) )
4148 case . array( let a) :
4249 . array( a. map ( \. describedByLoggingMetadata) )
50+ case . enumCase( let string) :
51+ . string( string)
52+ case . null:
53+ " nil "
54+ case . default:
55+ " <default> "
4356 default :
4457 . stringConvertible( self )
4558 }
Original file line number Diff line number Diff line change @@ -72,15 +72,15 @@ extension DatabaseQuery: CustomStringConvertible {
7272 }
7373 switch self . action {
7474 case . read, . aggregate, . custom:
75- result [ " unique " ] = " \ (self . isUnique) "
75+ result [ " unique " ] = . stringConvertible ( self . isUnique)
7676 result [ " fields " ] = . array( self . fields. map ( \. describedByLoggingMetadata) )
7777 result [ " joins " ] = . array( self . joins. map ( \. describedByLoggingMetadata) )
7878 fallthrough
7979 case . update, . delete:
8080 result [ " filters " ] = . array( self . filters. map ( \. describedByLoggingMetadata) )
8181 result [ " sorts " ] = . array( self . sorts. map ( \. describedByLoggingMetadata) )
82- result [ " limits " ] = . array( self . limits. map { . stringConvertible ( $0 ) } )
83- result [ " offsets " ] = . array( self . offsets. map { . stringConvertible ( $0 ) } )
82+ result [ " limits " ] = . array( self . limits. map ( \ . describedByLoggingMetadata ) )
83+ result [ " offsets " ] = . array( self . offsets. map ( \ . describedByLoggingMetadata ) )
8484 default : break
8585 }
8686 return result
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ func assertLastQuery(
3939}
4040
4141func env( _ name: String ) -> String ? {
42- return ProcessInfo . processInfo. environment [ name]
42+ ProcessInfo . processInfo. environment [ name]
4343}
4444
4545let isLoggingConfigured : Bool = {
You can’t perform that action at this time.
0 commit comments