Skip to content

Commit

Permalink
custom datatype (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanner0101 authored Jun 6, 2019
1 parent c33b5f0 commit 1bde239
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Sources/SQLKit/Query/SQLDataType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,26 @@ public enum SQLDataType: SQLExpression {
case text
case real
case blob
case custom(SQLExpression)

public func serialize(to serializer: inout SQLSerializer) {
let sql: String
let sql: SQLExpression
switch self {
case .smallint: sql = "SMALLINT"
case .int: sql = "INT"
case .bigint: sql = "BIGINT"
case .text: sql = "TEXT"
case .real: sql = "REAL"
case .blob: sql = "BLOB"
case .smallint:
sql = SQLRaw("SMALLINT")
case .int:
sql = SQLRaw("INTEGER")
case .bigint:
sql = SQLRaw("BIGINT")
case .text:
sql = SQLRaw("TEXT")
case .real:
sql = SQLRaw("REAL")
case .blob:
sql = SQLRaw("BLOB")
case .custom(let expression):
sql = expression
}
serializer.write(sql)
sql.serialize(to: &serializer)
}
}

0 comments on commit 1bde239

Please sign in to comment.