Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Sources/StructuredQueriesSQLiteCore/DatabaseFunction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public protocol DatabaseFunction<Input, Output> {
/// A type representing the function's return value.
associatedtype Output

associatedtype SwiftFunction

/// The name of the function.
var name: String { get }

Expand All @@ -18,6 +20,8 @@ public protocol DatabaseFunction<Input, Output> {
/// Whether or not the function is deterministic (or "pure" or "referentially transparent"),
/// _i.e._ given an input it will always return the same output.
var isDeterministic: Bool { get }

var body: SwiftFunction { get }
}

/// A type representing a scalar database function.
Expand Down Expand Up @@ -47,4 +51,8 @@ extension ScalarDatabaseFunction {
"\(quote: name)(\(Array(repeat each input).joined(separator: ", ")))"
)
}

public var wrappedValue: SwiftFunction {
body
}
}
1 change: 1 addition & 0 deletions Tests/StructuredQueriesTests/DatabaseFunctionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extension SnapshotTests {
└──────┘
"""
}
#expect($isEnabled.wrappedValue())
}

@DatabaseFunction
Expand Down