mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-23 04:04:22 +00:00
29 lines
973 B
Swift
29 lines
973 B
Swift
/// A [row value](https://www.sqlite.org/rowvalue.html).
|
|
///
|
|
/// :nodoc:
|
|
public struct _SQLRowValue: SQLExpression {
|
|
let expressions: [SQLExpression]
|
|
|
|
/// SQLite row values were shipped in SQLite 3.15:
|
|
/// https://www.sqlite.org/releaselog/3_15_0.html
|
|
static let isAvailable = (sqlite3_libversion_number() >= 3015000)
|
|
|
|
/// - precondition: `expressions` is not empty
|
|
init(_ expressions: [SQLExpression]) {
|
|
assert(!expressions.isEmpty)
|
|
self.expressions = expressions
|
|
}
|
|
|
|
public func _qualifiedExpression(with alias: TableAlias) -> SQLExpression {
|
|
_SQLRowValue(expressions.map { $0._qualifiedExpression(with: alias) })
|
|
}
|
|
|
|
public func _accept<Visitor: _SQLExpressionVisitor>(_ visitor: inout Visitor) throws {
|
|
if let expression = expressions.first, expressions.count == 1 {
|
|
try expression._accept(&visitor)
|
|
} else {
|
|
try visitor.visit(self)
|
|
}
|
|
}
|
|
}
|