File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ #if FluentSQLKitExtras
2+ import FluentKit
3+ import SQLKit
4+
5+ extension SQLQueryString {
6+ /// Allow specifying a Fluent keypath as an identifier interpolation in an `SQLQueryString`.
7+ @inlinable
8+ public mutating func appendInterpolation( ident: KeyPath < some Schema , some QueryAddressableProperty > ) {
9+ self . appendInterpolation ( . identifier( ident) )
10+ }
11+
12+ /// Allow specifying a Fluent keypath as an column interpolation in an `SQLQueryString`.
13+ @inlinable
14+ public mutating func appendInterpolation( col: KeyPath < some Schema , some QueryAddressableProperty > ) {
15+ self . appendInterpolation ( . column( col) )
16+ }
17+ }
18+ #endif
19+
Original file line number Diff line number Diff line change @@ -306,6 +306,12 @@ struct FluentSQLKitExtrasTests {
306306 #expect( MockSQLDatabase ( dialect: " mysql " ) . serialize ( . cast( \FooModel . $field, to: " text " ) ) . sql == #"CAST("foos"."field" AS text)"# )
307307 #expect( MockSQLDatabase ( dialect: " postgresql " ) . serialize ( . cast( \FooModel . $field, to: " text " ) ) . sql == #"CAST("foos"."field" AS "text")"# )
308308 }
309+
310+ @Test
311+ func queryStringExpression( ) {
312+ #expect( serialize ( " foo \( ident: \FooModel . $field) bar " as SQLQueryString ) == #"foo "field" bar"# )
313+ #expect( serialize ( " foo \( col: \FooModel . $field) bar " as SQLQueryString ) == #"foo "foos"."field" bar"# )
314+ }
309315 }
310316}
311317
You can’t perform that action at this time.
0 commit comments