diff --git a/Sources/SwiftKuery/QueryBuilder.swift b/Sources/SwiftKuery/QueryBuilder.swift index ce974570..ca6b0438 100644 --- a/Sources/SwiftKuery/QueryBuilder.swift +++ b/Sources/SwiftKuery/QueryBuilder.swift @@ -57,6 +57,8 @@ public class QueryBuilder { case double /// The database type that corresponds to char. case char + /// The database type that corresponds to UUID. Accepts a string representation of UUID. + case uuid /// Last case, add new values before it. case namesCount @@ -115,6 +117,7 @@ public class QueryBuilder { substitutions[QuerySubstitutionNames.float.rawValue] = "real" substitutions[QuerySubstitutionNames.double.rawValue] = "double" substitutions[QuerySubstitutionNames.char.rawValue] = "char" + substitutions[QuerySubstitutionNames.uuid.rawValue] = "varchar(36)" self.addNumbersToParameters = addNumbersToParameters self.anyOnSubquerySupported = anyOnSubquerySupported diff --git a/Sources/SwiftKuery/SQLDataType.swift b/Sources/SwiftKuery/SQLDataType.swift index f406266f..1a235b57 100644 --- a/Sources/SwiftKuery/SQLDataType.swift +++ b/Sources/SwiftKuery/SQLDataType.swift @@ -14,6 +14,8 @@ limitations under the License. */ +import Foundation + // MARK: SQLDataType protocol /// Defines the protocol for data types to be used as table column types. @@ -150,5 +152,15 @@ extension Bool: SQLDataType { } } +extension UUID: SQLDataType { + /// Return database specific representation of the UUID type using `QueryBuilder`. + /// + /// - Parameter queryBuilder: The QueryBuilder to use. + /// - Returns: A String representation of the type. + public static func create(queryBuilder: QueryBuilder) -> String { + return queryBuilder.substitutions[QueryBuilder.QuerySubstitutionNames.uuid.rawValue] + } +} + diff --git a/docs/Classes.html b/docs/Classes.html index 2cabaea1..75df5a5f 100644 --- a/docs/Classes.html +++ b/docs/Classes.html @@ -137,6 +137,9 @@ + + + + + + + + +
+ +
diff --git a/docs/Classes/Table.html b/docs/Classes/Table.html index ffba5718..fe3faf6c 100644 --- a/docs/Classes/Table.html +++ b/docs/Classes/Table.html @@ -138,6 +138,9 @@ + + + + + + + + + + + +
  • +
    + + + + UUID + +
    +
    +
    +
    +
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConvertible
    + +
    +
    +
    +
    +
  • @@ -2268,7 +2298,7 @@

    Declaration

    diff --git a/docs/Extensions/Bool.html b/docs/Extensions/Bool.html index 0e2d7c02..caf6937e 100644 --- a/docs/Extensions/Bool.html +++ b/docs/Extensions/Bool.html @@ -138,6 +138,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    diff --git a/docs/docsets/SwiftKuery.docset/Contents/Resources/Documents/Classes/Table.html b/docs/docsets/SwiftKuery.docset/Contents/Resources/Documents/Classes/Table.html index ffba5718..fe3faf6c 100644 --- a/docs/docsets/SwiftKuery.docset/Contents/Resources/Documents/Classes/Table.html +++ b/docs/docsets/SwiftKuery.docset/Contents/Resources/Documents/Classes/Table.html @@ -138,6 +138,9 @@ + + + + + + + + + + + +
  • +
    + + + + UUID + +
    +
    +
    +
    +
    +
    + + See more +
    +
    +

    Declaration

    +
    +

    Swift

    +
    struct UUID : ReferenceConvertible, Hashable, Equatable, CustomStringConvertible
    + +
    +
    +
    +
    +
  • @@ -2268,7 +2298,7 @@

    Declaration

    diff --git a/docs/docsets/SwiftKuery.docset/Contents/Resources/Documents/Extensions/Bool.html b/docs/docsets/SwiftKuery.docset/Contents/Resources/Documents/Extensions/Bool.html index 0e2d7c02..caf6937e 100644 --- a/docs/docsets/SwiftKuery.docset/Contents/Resources/Documents/Extensions/Bool.html +++ b/docs/docsets/SwiftKuery.docset/Contents/Resources/Documents/Extensions/Bool.html @@ -138,6 +138,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +