Skip to content

Commit

Permalink
Merge pull request #46 from vapor/3-release
Browse files Browse the repository at this point in the history
3.0 release doc blocks
  • Loading branch information
tanner0101 authored Jul 17, 2018
2 parents e319a3b + 7e6d98e commit 635ad49
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 4 deletions.
1 change: 1 addition & 0 deletions Sources/SQLite/Row/SQLiteColumn.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Column in a SQLite result set.
public struct SQLiteColumn {
/// The table name.
public var table: String?
Expand Down
20 changes: 19 additions & 1 deletion Sources/SQLite/Row/SQLiteData.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
/// Supported SQLite data types.
public enum SQLiteData: Equatable, Encodable {
/// `Int`.
case integer(Int)

/// `Double`.
case float(Double)

/// `String`.
case text(String)

/// `Data`.
case blob(Foundation.Data)

/// `NULL`.
case null

/// See `Encodable`.
public func encode(to encoder: Encoder) throws {
fatalError()
var container = encoder.singleValueContainer()
switch self {
case .integer(let value): try container.encode(value)
case .float(let value): try container.encode(value)
case .text(let value): try container.encode(value)
case .blob(let value): try container.encode(value)
case .null: try container.encodeNil()
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions Sources/SQLite/Row/SQLiteDataConvertible.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/// Capable of converting to and from `SQLiteData`.
public protocol SQLiteDataConvertible {
/// Creates `Self` from `SQLiteData`.
static func convertFromSQLiteData(_ data: SQLiteData) throws -> Self

/// Converts `self` to `SQLiteData`.
func convertToSQLiteData() throws -> SQLiteData
}

Expand Down
10 changes: 10 additions & 0 deletions Sources/SQLite/Row/SQLiteDataType.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// Supported SQLite column data types when defining schemas.
public enum SQLiteDataType: SQLDataType {
/// See `SQLDataType`.
public static func dataType(appropriateFor type: Any.Type) -> SQLiteDataType? {
Expand All @@ -7,10 +8,19 @@ public enum SQLiteDataType: SQLDataType {
return nil
}

/// `INTEGER`.
case integer

/// `REAL`.
case real

/// `TEXT`.
case text

/// `BLOB`.
case blob

/// `NULL`.
case null

/// See `SQLSerializable`.
Expand Down
6 changes: 6 additions & 0 deletions Sources/SQLite/SQL/SQLiteBind.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// SQLite specific `SQLBind`.
public struct SQLiteBind: SQLBind {
/// See `SQLBind`.
public static func encodable<E>(_ value: E) -> SQLiteBind
Expand All @@ -10,11 +11,16 @@ public struct SQLiteBind: SQLBind {
}
}

/// Supported bind values.
public enum Value {
/// A sub-expression.
case expression(SQLiteExpression)

/// Encodable value.
case encodable(Encodable)
}

/// Bind value.
public var value: Value

/// See `SQLSerializable`.
Expand Down
4 changes: 4 additions & 0 deletions Sources/SQLite/SQL/SQLiteBoolLiteral.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// SQLite specific `SQLBoolLiteral`.
public enum SQLiteBoolLiteral: SQLBoolLiteral {
/// See `SQLBoolLiteral`.
public static var `true`: SQLiteBoolLiteral {
Expand All @@ -9,7 +10,10 @@ public enum SQLiteBoolLiteral: SQLBoolLiteral {
return ._false
}

/// See `SQLBoolLiteral`.
case _true

/// See `SQLBoolLiteral`.
case _false

/// See `SQLSerializable`.
Expand Down
1 change: 1 addition & 0 deletions Sources/SQLite/SQL/SQLiteCollation.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// SQLite specific `SQLCollation`.
public enum SQLiteCollation: SQLCollation {
/// See `SQLSerializable`.
public func serialize(_ binds: inout [Encodable]) -> String {
Expand Down
1 change: 1 addition & 0 deletions Sources/SQLite/SQL/SQLiteDefaultLiteral.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// SQLite specific `SQLDefaultLiteral`.
public struct SQLiteDefaultLiteral: SQLDefaultLiteral {
/// See `SQLDefaultLiteral`.
public static var `default`: SQLiteDefaultLiteral {
Expand Down
4 changes: 4 additions & 0 deletions Sources/SQLite/SQL/SQLiteDropIndex.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/// SQLite specific `SQLDropIndex`.
public struct SQLiteDropIndex: SQLDropIndex {
/// See `SQLDropIndex`.
public var identifier: SQLiteIdentifier

/// See `SQLSerializable`.
Expand All @@ -10,6 +12,7 @@ public struct SQLiteDropIndex: SQLDropIndex {
}
}

/// SQLite specific drop index builder.
public final class SQLiteDropIndexBuilder<Connection>: SQLQueryBuilder
where Connection: SQLConnection, Connection.Query == SQLiteQuery
{
Expand All @@ -33,6 +36,7 @@ public final class SQLiteDropIndexBuilder<Connection>: SQLQueryBuilder


extension SQLConnection where Query == SQLiteQuery {
/// Drops an index from a SQLite database.
public func drop(index identifier: SQLiteIdentifier) -> SQLiteDropIndexBuilder<Self> {
return .init(SQLiteDropIndex(identifier: identifier), on: self)
}
Expand Down
9 changes: 9 additions & 0 deletions Sources/SQLite/SQL/SQLiteFunction.swift
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
/// SQLite specific `SQLFunction`.
public struct SQLiteFunction: SQLFunction {
/// See `SQLFunction`.
public typealias Argument = GenericSQLFunctionArgument<SQLiteExpression>

/// `COUNT(*)`.
public static var count: SQLiteFunction {
return .init(name: "COUNT", arguments: [.all])
}

/// See `SQLFunction`.
public static func function(_ name: String, _ args: [Argument]) -> SQLiteFunction {
return .init(name: name, arguments: args)
}

/// See `SQLFunction`.
public let name: String

/// See `SQLFunction`.
public let arguments: [Argument]

/// See `SQLSerializable`.
public func serialize(_ binds: inout [Encodable]) -> String {
return name + "(" + arguments.map { $0.serialize(&binds) }.joined(separator: ", ") + ")"
}
}

extension SQLSelectExpression where Expression.Function == SQLiteFunction, Identifier == SQLiteIdentifier {
/// `COUNT(*) as ...`.
public static func count(as alias: SQLiteIdentifier? = nil) -> Self {
return .expression(.function(.count), alias: alias)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/SQLite/SQL/SQLitePrimaryKey.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// SQLite specific `SQLPrimaryKeyDefault`.
public enum SQLitePrimaryKeyDefault: SQLPrimaryKeyDefault {
/// See `SQLPrimaryKey`.
public static var `default`: SQLitePrimaryKeyDefault {
Expand Down
1 change: 1 addition & 0 deletions Sources/SQLite/SQL/SQLiteQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public enum SQLiteQuery: SQLQuery {
}

extension SQLiteQuery: ExpressibleByStringLiteral {
/// See `ExpressibleByStringLiteral`.
public init(stringLiteral value: String) {
self = ._raw(value, [])
}
Expand Down
1 change: 1 addition & 0 deletions Sources/SQLite/SQL/SQLiteTable.swift
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// SQLite specific `SQLTable`.
public protocol SQLiteTable: SQLTable { }
4 changes: 1 addition & 3 deletions Sources/SQLite/Utilities/Deprecated.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
/// - warning: Deprecated.
@available(*, deprecated, renamed: "SQLiteDataType")
public typealias SQLiteFieldType = SQLiteDataType
/// nothing here... yet
8 changes: 8 additions & 0 deletions Sources/SQLite/Utilities/SQLiteError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ import Debugging
/// Errors that can be thrown while using SQLite
public struct SQLiteError: Debuggable {
let problem: Problem

/// See `Debuggable`.
public let reason: String

/// See `Debuggable`.
public var sourceLocation: SourceLocation?

/// See `Debuggable`.
public var stackTrace: [String]

/// See `Debuggable`.
public var identifier: String {
return problem.rawValue
}
Expand Down

0 comments on commit 635ad49

Please sign in to comment.