Skip to content

Commit 4b9be8f

Browse files
committed
wip
1 parent f168bb1 commit 4b9be8f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Sources/StructuredQueriesSQLite/Macros.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import StructuredQueriesSQLiteCore
22

3+
/// Defines and implements a conformance to the ``/StructuredQueriesSQLiteCore/DatabaseFunction``
4+
/// protocol.
5+
///
6+
/// - Parameters
7+
/// - name: The function's name. Defaults to the name of the function the macro is applied to.
8+
/// - isDeterministic: Whether or not the function is deterministic (or "pure" or "referentially
9+
/// transparent"), _i.e._ given an input it will always return the same output.
310
@attached(peer, names: overloaded, prefixed(`$`))
411
public macro DatabaseFunction(
512
_ name: String = "",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1+
/// A type representing a database function.
2+
///
3+
/// Don't conform to this protocol directly. Instead, use the `@DatabaseFunction` macros to
4+
/// generate a conformance.
15
public protocol DatabaseFunction {
6+
/// The name of the function.
27
var name: String { get }
8+
9+
/// The number of arguments the function accepts.
310
var argumentCount: Int? { get }
11+
12+
/// Whether or not the function is deterministic (or "pure" or "referentially transparent"),
13+
/// _i.e._ given an input it will always return the same output.
414
var isDeterministic: Bool { get }
15+
16+
/// The function body. Transforms a collection of bindings handed to the function into a binding
17+
/// returned to the query.
18+
///
19+
/// - Parameter arguments: Arguments passed to the database function.
20+
/// - Returns: A value returned from the database function.
521
func invoke(_ arguments: [QueryBinding]) -> QueryBinding
622
}

0 commit comments

Comments
 (0)