Skip to content

Commit afdc819

Browse files
committed
wip
1 parent 2206af7 commit afdc819

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Sources/StructuredQueriesCore/ScalarFunctions.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ extension QueryExpression where QueryValue: FloatingPoint {
120120
}
121121
}
122122

123-
extension QueryExpression where QueryValue: Numeric {
123+
extension QueryExpression
124+
where QueryValue: _OptionalPromotable, QueryValue._Optionalized.Wrapped: Numeric {
124125
/// Wraps this numeric query expression with the `abs` function.
125126
///
126127
/// - Returns: An expression wrapped with the `abs` function.
@@ -251,14 +252,18 @@ extension QueryExpression where QueryValue == String {
251252
public func instr(_ occurrence: some QueryExpression<QueryValue>) -> some QueryExpression<Int> {
252253
QueryFunction("instr", self, occurrence)
253254
}
255+
}
254256

257+
extension QueryExpression where QueryValue: _OptionalPromotable<String?> {
255258
/// Wraps this string expression with the `lower` function.
256259
///
257260
/// - Returns: An expression wrapped with the `lower` function.
258-
public func lower() -> some QueryExpression<QueryValue> {
261+
public func lower() -> some QueryExpression<QueryValue._Optionalized> {
259262
QueryFunction("lower", self)
260263
}
264+
}
261265

266+
extension QueryExpression where QueryValue == String {
262267
/// Wraps this string expression with the `ltrim` function.
263268
///
264269
/// - Parameter characters: Characters to trim.
@@ -279,14 +284,18 @@ extension QueryExpression where QueryValue == String {
279284
public func octetLength() -> some QueryExpression<Int> {
280285
QueryFunction("octet_length", self)
281286
}
287+
}
282288

289+
extension QueryExpression where QueryValue: _OptionalPromotable<String?> {
283290
/// Wraps this string expression with the `quote` function.
284291
///
285292
/// - Returns: An expression wrapped with the `quote` function.
286-
public func quote() -> some QueryExpression<QueryValue> {
293+
public func quote() -> some QueryExpression<QueryValue._Optionalized> {
287294
QueryFunction("quote", self)
288295
}
296+
}
289297

298+
extension QueryExpression where QueryValue == String {
290299
/// Creates an expression invoking the `replace` function.
291300
///
292301
/// - Parameters:
@@ -346,13 +355,15 @@ extension QueryExpression where QueryValue == String {
346355
return QueryFunction("trim", self)
347356
}
348357
}
358+
}
349359

360+
extension QueryExpression where QueryValue: _OptionalPromotable<String?> {
350361
/// Wraps this string query expression with the `unhex` function.
351362
///
352363
/// - Parameter characters: Non-hexadecimal characters to skip.
353364
/// - Returns: An optional blob expression of the `unhex` function wrapping this expression.
354365
public func unhex(
355-
_ characters: (some QueryExpression<QueryValue>)? = QueryValue?.none
366+
_ characters: (some QueryExpression<String>)? = String?.none
356367
) -> some QueryExpression<[UInt8]?> {
357368
if let characters {
358369
return QueryFunction("unhex", self, characters)

0 commit comments

Comments
 (0)