Skip to content

Commit a8bab56

Browse files
committed
format
1 parent 91c30af commit a8bab56

File tree

3 files changed

+91
-91
lines changed

3 files changed

+91
-91
lines changed

Sources/SQLite/Core/Statement.swift

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public final class Statement {
166166

167167
reset(clearBindings: false)
168168
_ = try step()
169-
return try row.getValue(0)
169+
return try row.getValue(0)
170170
}
171171

172172
/// - Parameter bindings: A list of parameters to bind to the statement.
@@ -259,83 +259,83 @@ extension Statement: CustomStringConvertible {
259259
}
260260

261261
public protocol CursorProtocol {
262-
func getValue(_ idx: Int) throws -> Binding?
263-
func getValue(_ idx: Int) throws -> Double
264-
func getValue(_ idx: Int) throws -> Int64
265-
func getValue(_ idx: Int) throws -> String
266-
func getValue(_ idx: Int) throws -> Blob
262+
func getValue(_ idx: Int) throws -> Binding?
263+
func getValue(_ idx: Int) throws -> Double
264+
func getValue(_ idx: Int) throws -> Int64
265+
func getValue(_ idx: Int) throws -> String
266+
func getValue(_ idx: Int) throws -> Blob
267267
}
268268

269269
extension CursorProtocol {
270-
public func getValue<T: Binding>(_ idx: Int) -> T? {
271-
switch T.self {
272-
case is Double.Type:
273-
return try? getValue(idx) as Double as? T
274-
case is Int64.Type:
275-
return try? getValue(idx) as Int64 as? T
276-
case is String.Type:
277-
return try? getValue(idx) as String as? T
278-
case is Blob.Type:
279-
return try? getValue(idx) as Blob as? T
280-
default:
281-
return nil
282-
}
283-
}
284-
285-
public func getValue(_ idx: Int) throws -> Bool {
286-
try Bool.fromDatatypeValue(getValue(idx))
287-
}
288-
289-
public func getValue(_ idx: Int) throws -> Int {
290-
try Int.fromDatatypeValue(getValue(idx))
291-
}
270+
public func getValue<T: Binding>(_ idx: Int) -> T? {
271+
switch T.self {
272+
case is Double.Type:
273+
return try? getValue(idx) as Double as? T
274+
case is Int64.Type:
275+
return try? getValue(idx) as Int64 as? T
276+
case is String.Type:
277+
return try? getValue(idx) as String as? T
278+
case is Blob.Type:
279+
return try? getValue(idx) as Blob as? T
280+
default:
281+
return nil
282+
}
283+
}
284+
285+
public func getValue(_ idx: Int) throws -> Bool {
286+
try Bool.fromDatatypeValue(getValue(idx))
287+
}
288+
289+
public func getValue(_ idx: Int) throws -> Int {
290+
try Int.fromDatatypeValue(getValue(idx))
291+
}
292292
}
293293

294294
struct CursorWithBindingArray: CursorProtocol {
295-
let elements: [Binding?]
296-
init(elements: [Binding?]) {
297-
self.elements = elements
298-
}
299-
300-
func getValue(_ idx: Int) throws -> Binding? {
301-
elements[idx]
302-
}
303-
func getValue(_ idx: Int) throws -> Double {
304-
guard let value = elements[idx] as? Double else {
305-
throw QueryError.unexpectedNullValue(name: "column at index \(idx)")
306-
}
307-
return value
308-
}
309-
func getValue(_ idx: Int) throws -> Int64 {
310-
guard let value = elements[idx] as? Int64 else {
311-
throw QueryError.unexpectedNullValue(name: "column at index \(idx)")
312-
}
313-
return value
314-
}
315-
func getValue(_ idx: Int) throws -> String {
316-
guard let value = elements[idx] as? String else {
317-
throw QueryError.unexpectedNullValue(name: "column at index \(idx)")
318-
}
319-
return value
320-
}
321-
func getValue(_ idx: Int) throws -> Blob {
322-
guard let value = elements[idx] as? Blob else {
323-
throw QueryError.unexpectedNullValue(name: "column at index \(idx)")
324-
}
325-
return value
326-
}
295+
let elements: [Binding?]
296+
init(elements: [Binding?]) {
297+
self.elements = elements
298+
}
299+
300+
func getValue(_ idx: Int) throws -> Binding? {
301+
elements[idx]
302+
}
303+
func getValue(_ idx: Int) throws -> Double {
304+
guard let value = elements[idx] as? Double else {
305+
throw QueryError.unexpectedNullValue(name: "column at index \(idx)")
306+
}
307+
return value
308+
}
309+
func getValue(_ idx: Int) throws -> Int64 {
310+
guard let value = elements[idx] as? Int64 else {
311+
throw QueryError.unexpectedNullValue(name: "column at index \(idx)")
312+
}
313+
return value
314+
}
315+
func getValue(_ idx: Int) throws -> String {
316+
guard let value = elements[idx] as? String else {
317+
throw QueryError.unexpectedNullValue(name: "column at index \(idx)")
318+
}
319+
return value
320+
}
321+
func getValue(_ idx: Int) throws -> Blob {
322+
guard let value = elements[idx] as? Blob else {
323+
throw QueryError.unexpectedNullValue(name: "column at index \(idx)")
324+
}
325+
return value
326+
}
327327
}
328328

329329
public struct Cursor: CursorProtocol {
330330
fileprivate let statement: Statement
331-
fileprivate var handle: OpaquePointer {
332-
statement.handle!
333-
}
331+
fileprivate var handle: OpaquePointer {
332+
statement.handle!
333+
}
334334

335335
fileprivate let columnCount: Int
336336

337337
fileprivate init(_ statement: Statement) {
338-
self.statement = statement
338+
self.statement = statement
339339
columnCount = statement.columnCount
340340
}
341341

@@ -348,9 +348,9 @@ public struct Cursor: CursorProtocol {
348348
}
349349

350350
public func getValue(_ idx: Int) throws -> String {
351-
guard let text = sqlite3_column_text(handle, Int32(idx)) else {
352-
throw QueryError.unexpectedNullValue(name: "column at index \(idx)")
353-
}
351+
guard let text = sqlite3_column_text(handle, Int32(idx)) else {
352+
throw QueryError.unexpectedNullValue(name: "column at index \(idx)")
353+
}
354354
return String(cString: UnsafePointer(text))
355355
}
356356

Sources/SQLite/Schema/Connection+Schema.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public extension Connection {
1515
func foreignKeyCheck(table: String? = nil) throws -> [ForeignKeyError] {
1616
try run("PRAGMA foreign_key_check" + (table.map { "(\($0.quote()))" } ?? ""))
1717
.compactMap { (row: Cursor) -> ForeignKeyError? in
18-
guard let table = row.getValue(0) as String?,
18+
guard let table = row.getValue(0) as String?,
1919
let rowId = row.getValue(1) as Int64?,
2020
let target = row.getValue(2) as String? else { return nil }
2121

Sources/SQLite/Typed/Query+Lazy.swift

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

2525
extension Array where Element == LazySequence<AnyIterator<Row>> {
26-
@available(swift, deprecated: 1, message: "Please use return value of prepare as Array directly")
27-
public init(_ values: Element) {
28-
preconditionFailure("Please use return value of prepare as Array directly")
29-
}
26+
@available(swift, deprecated: 1, message: "Please use return value of prepare as Array directly")
27+
public init(_ values: Element) {
28+
preconditionFailure("Please use return value of prepare as Array directly")
29+
}
3030
}
3131

3232
extension Connection {
33-
@_disfavoredOverload
34-
public func prepare(_ query: QueryType) throws -> [Row] {
35-
let expression = query.expression
36-
let statement = try prepare(expression.template, expression.bindings)
33+
@_disfavoredOverload
34+
public func prepare(_ query: QueryType) throws -> [Row] {
35+
let expression = query.expression
36+
let statement = try prepare(expression.template, expression.bindings)
3737

38-
let columnNames = try columnNamesForQuery(query)
38+
let columnNames = try columnNamesForQuery(query)
3939

40-
return Array(AnyIterator {
41-
statement.next().map { cursor in
42-
Row(columnNames, (0..<columnNames.count).map({
43-
try? cursor.getValue($0) as Binding?
44-
}))
45-
}
46-
})
47-
}
40+
return Array(AnyIterator {
41+
statement.next().map { cursor in
42+
Row(columnNames, (0..<columnNames.count).map({
43+
try? cursor.getValue($0) as Binding?
44+
}))
45+
}
46+
})
47+
}
4848

49-
public func prepare(_ query: QueryType) throws -> LazySequence<AnyIterator<Row>> {
50-
let expression = query.expression
51-
let statement = try prepare(expression.template, expression.bindings)
49+
public func prepare(_ query: QueryType) throws -> LazySequence<AnyIterator<Row>> {
50+
let expression = query.expression
51+
let statement = try prepare(expression.template, expression.bindings)
5252

53-
let columnNames = try columnNamesForQuery(query)
53+
let columnNames = try columnNamesForQuery(query)
5454

55-
return AnyIterator { statement.next().map { Row(columnNames, $0) } }.lazy
56-
}
55+
return AnyIterator { statement.next().map { Row(columnNames, $0) } }.lazy
56+
}
5757
}

0 commit comments

Comments
 (0)