Skip to content

Commit 0ca88c3

Browse files
committed
Rename Expression to SQLExpression to avoid Swift 6 name conflicts
1 parent e65ff1b commit 0ca88c3

34 files changed

+921
-920
lines changed

Sources/SQLiteDB/Extensions/FTS4.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ extension VirtualTable {
5151
///
5252
/// - Returns: An expression appended with a `MATCH` query against the given
5353
/// pattern.
54-
public func match(_ pattern: String) -> Expression<Bool> {
54+
public func match(_ pattern: String) -> SQLExpression<Bool> {
5555
"MATCH".infix(tableName(), pattern)
5656
}
5757

58-
public func match(_ pattern: Expression<String>) -> Expression<Bool> {
58+
public func match(_ pattern: SQLExpression<String>) -> SQLExpression<Bool> {
5959
"MATCH".infix(tableName(), pattern)
6060
}
6161

62-
public func match(_ pattern: Expression<String?>) -> Expression<Bool?> {
62+
public func match(_ pattern: SQLExpression<String?>) -> SQLExpression<Bool?> {
6363
"MATCH".infix(tableName(), pattern)
6464
}
6565

@@ -77,11 +77,11 @@ extension VirtualTable {
7777
filter(match(pattern))
7878
}
7979

80-
public func match(_ pattern: Expression<String>) -> QueryType {
80+
public func match(_ pattern: SQLExpression<String>) -> QueryType {
8181
filter(match(pattern))
8282
}
8383

84-
public func match(_ pattern: Expression<String?>) -> QueryType {
84+
public func match(_ pattern: SQLExpression<String?>) -> QueryType {
8585
filter(match(pattern))
8686
}
8787

@@ -209,7 +209,7 @@ open class FTSConfig {
209209
var options = Options()
210210
options.append(formatColumnDefinitions())
211211
if let tokenizer {
212-
options.append("tokenize", value: Expression<Void>(literal: tokenizer.description))
212+
options.append("tokenize", value: SQLExpression<Void>(literal: tokenizer.description))
213213
}
214214
options.appendCommaSeparated("prefix", values: prefixes.sorted().map { String($0) })
215215
if isContentless {
@@ -237,11 +237,11 @@ open class FTSConfig {
237237
}
238238

239239
@discardableResult mutating func append(_ key: String, value: String) -> Options {
240-
append(key, value: Expression<String>(value))
240+
append(key, value: SQLExpression<String>(value))
241241
}
242242

243243
@discardableResult mutating func append(_ key: String, value: Expressible) -> Options {
244-
arguments.append("=".join([Expression<Void>(literal: key), value]))
244+
arguments.append("=".join([SQLExpression<Void>(literal: key), value]))
245245
return self
246246
}
247247
}

Sources/SQLiteDB/Extensions/FTS5.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ open class FTS5Config: FTSConfig {
7373
options.append("content_rowid", value: contentRowId)
7474
}
7575
if let columnSize {
76-
options.append("columnsize", value: Expression<Int>(value: columnSize))
76+
options.append("columnsize", value: SQLExpression<Int>(value: columnSize))
7777
}
7878
if let detail {
7979
options.append("detail", value: detail.rawValue)
@@ -84,7 +84,7 @@ open class FTS5Config: FTSConfig {
8484
override func formatColumnDefinitions() -> [Expressible] {
8585
columnDefinitions.map { definition in
8686
if definition.options.contains(.unindexed) {
87-
return " ".join([definition.0, Expression<Void>(literal: "UNINDEXED")])
87+
return " ".join([definition.0, SQLExpression<Void>(literal: "UNINDEXED")])
8888
} else {
8989
return definition.0
9090
}

Sources/SQLiteDB/Extensions/RTree.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
//
2424

2525
extension Module {
26-
public static func RTree<T: Value, U: Value>(_ primaryKey: Expression<T>,
27-
_ pairs: (Expression<U>, Expression<U>)...)
26+
public static func RTree<T: Value, U: Value>(_ primaryKey: SQLExpression<T>,
27+
_ pairs: (SQLExpression<U>, SQLExpression<U>)...)
2828
-> Module where T.Datatype == Int64, U.Datatype == Double {
2929
var arguments: [Expressible] = [primaryKey]
3030

Sources/SQLiteDB/Helpers.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ import CSQLite
3232
import SQLite3
3333
#endif
3434

35-
public typealias Star = (Expression<Binding>?, Expression<Binding>?) -> Expression<Void>
35+
public typealias Star = (SQLExpression<Binding>?, SQLExpression<Binding>?) -> SQLExpression<Void>
3636

37-
public func *(_: Expression<Binding>?, _: Expression<Binding>?) -> Expression<Void> {
38-
Expression(literal: "*")
37+
public func *(_: SQLExpression<Binding>?, _: SQLExpression<Binding>?) -> SQLExpression<Void> {
38+
SQLExpression(literal: "*")
3939
}
4040

4141
// swiftlint:disable:next type_name
@@ -75,34 +75,34 @@ extension String {
7575
template.append(expression.template)
7676
bindings.append(contentsOf: expression.bindings)
7777
}
78-
return Expression<Void>(template.joined(separator: self), bindings)
78+
return SQLExpression<Void>(template.joined(separator: self), bindings)
7979
}
8080

81-
func infix<T>(_ lhs: Expressible, _ rhs: Expressible, wrap: Bool = true) -> Expression<T> {
81+
func infix<T>(_ lhs: Expressible, _ rhs: Expressible, wrap: Bool = true) -> SQLExpression<T> {
8282
infix([lhs, rhs], wrap: wrap)
8383
}
8484

85-
func infix<T>(_ terms: [Expressible], wrap: Bool = true) -> Expression<T> {
86-
let expression = Expression<T>(" \(self) ".join(terms).expression)
85+
func infix<T>(_ terms: [Expressible], wrap: Bool = true) -> SQLExpression<T> {
86+
let expression = SQLExpression<T>(" \(self) ".join(terms).expression)
8787
guard wrap else {
8888
return expression
8989
}
9090
return "".wrap(expression)
9191
}
9292

9393
func prefix(_ expressions: Expressible) -> Expressible {
94-
"\(self) ".wrap(expressions) as Expression<Void>
94+
"\(self) ".wrap(expressions) as SQLExpression<Void>
9595
}
9696

9797
func prefix(_ expressions: [Expressible]) -> Expressible {
98-
"\(self) ".wrap(expressions) as Expression<Void>
98+
"\(self) ".wrap(expressions) as SQLExpression<Void>
9999
}
100100

101-
func wrap<T>(_ expression: Expressible) -> Expression<T> {
102-
Expression("\(self)(\(expression.expression.template))", expression.expression.bindings)
101+
func wrap<T>(_ expression: Expressible) -> SQLExpression<T> {
102+
SQLExpression("\(self)(\(expression.expression.template))", expression.expression.bindings)
103103
}
104104

105-
func wrap<T>(_ expressions: [Expressible]) -> Expression<T> {
105+
func wrap<T>(_ expressions: [Expressible]) -> SQLExpression<T> {
106106
wrap(", ".join(expressions))
107107
}
108108

Sources/SQLiteDB/Schema/SchemaReader.swift

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -141,54 +141,54 @@ private enum SchemaTable {
141141
}
142142

143143
// columns
144-
static let typeColumn = Expression<String>("type")
145-
static let nameColumn = Expression<String>("name")
146-
static let tableNameColumn = Expression<String>("tbl_name")
147-
static let rootPageColumn = Expression<Int64?>("rootpage")
148-
static let sqlColumn = Expression<String?>("sql")
144+
static let typeColumn = SQLExpression<String>("type")
145+
static let nameColumn = SQLExpression<String>("name")
146+
static let tableNameColumn = SQLExpression<String>("tbl_name")
147+
static let rootPageColumn = SQLExpression<Int64?>("rootpage")
148+
static let sqlColumn = SQLExpression<String?>("sql")
149149
}
150150

151151
private enum TableInfoTable {
152-
static let idColumn = Expression<Int64>("cid")
153-
static let nameColumn = Expression<String>("name")
154-
static let typeColumn = Expression<String>("type")
155-
static let notNullColumn = Expression<Int64>("notnull")
156-
static let defaultValueColumn = Expression<String?>("dflt_value")
157-
static let primaryKeyColumn = Expression<Int64?>("pk")
152+
static let idColumn = SQLExpression<Int64>("cid")
153+
static let nameColumn = SQLExpression<String>("name")
154+
static let typeColumn = SQLExpression<String>("type")
155+
static let notNullColumn = SQLExpression<Int64>("notnull")
156+
static let defaultValueColumn = SQLExpression<String?>("dflt_value")
157+
static let primaryKeyColumn = SQLExpression<Int64?>("pk")
158158
}
159159

160160
private enum IndexInfoTable {
161161
// The rank of the column within the index. (0 means left-most.)
162-
static let seqnoColumn = Expression<Int64>("seqno")
162+
static let seqnoColumn = SQLExpression<Int64>("seqno")
163163
// The rank of the column within the table being indexed.
164164
// A value of -1 means rowid and a value of -2 means that an expression is being used.
165-
static let cidColumn = Expression<Int64>("cid")
165+
static let cidColumn = SQLExpression<Int64>("cid")
166166
// The name of the column being indexed. This columns is NULL if the column is the rowid or an expression.
167-
static let nameColumn = Expression<String?>("name")
167+
static let nameColumn = SQLExpression<String?>("name")
168168
}
169169

170170
private enum IndexListTable {
171171
// A sequence number assigned to each index for internal tracking purposes.
172-
static let seqColumn = Expression<Int64>("seq")
172+
static let seqColumn = SQLExpression<Int64>("seq")
173173
// The name of the index
174-
static let nameColumn = Expression<String>("name")
174+
static let nameColumn = SQLExpression<String>("name")
175175
// "1" if the index is UNIQUE and "0" if not.
176-
static let uniqueColumn = Expression<Int64>("unique")
176+
static let uniqueColumn = SQLExpression<Int64>("unique")
177177
// "c" if the index was created by a CREATE INDEX statement,
178178
// "u" if the index was created by a UNIQUE constraint, or
179179
// "pk" if the index was created by a PRIMARY KEY constraint.
180-
static let originColumn = Expression<String>("origin")
180+
static let originColumn = SQLExpression<String>("origin")
181181
// "1" if the index is a partial index and "0" if not.
182-
static let partialColumn = Expression<Int64>("partial")
182+
static let partialColumn = SQLExpression<Int64>("partial")
183183
}
184184

185185
private enum ForeignKeyListTable {
186-
static let idColumn = Expression<Int64>("id")
187-
static let seqColumn = Expression<Int64>("seq")
188-
static let tableColumn = Expression<String>("table")
189-
static let fromColumn = Expression<String>("from")
190-
static let toColumn = Expression<String?>("to") // when null, use primary key
191-
static let onUpdateColumn = Expression<String>("on_update")
192-
static let onDeleteColumn = Expression<String>("on_delete")
193-
static let matchColumn = Expression<String>("match")
186+
static let idColumn = SQLExpression<Int64>("id")
187+
static let seqColumn = SQLExpression<Int64>("seq")
188+
static let tableColumn = SQLExpression<String>("table")
189+
static let fromColumn = SQLExpression<String>("from")
190+
static let toColumn = SQLExpression<String?>("to") // when null, use primary key
191+
static let onUpdateColumn = SQLExpression<String>("on_update")
192+
static let onDeleteColumn = SQLExpression<String>("on_delete")
193+
static let matchColumn = SQLExpression<String>("match")
194194
}

0 commit comments

Comments
 (0)