From 86e1a41726df2dd8d96d7f2fa1f4a9650607daa4 Mon Sep 17 00:00:00 2001 From: collinhundley Date: Tue, 2 Aug 2016 18:52:49 -0600 Subject: [PATCH 01/10] Update dependency to collinhundley/cmysql --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index ccee9da1..6b698c31 100644 --- a/Package.swift +++ b/Package.swift @@ -3,6 +3,6 @@ import PackageDescription let package = Package( name: "MySQL", dependencies: [ - .Package(url: "https://github.com/qutheory/cmysql.git", majorVersion: 0, minor: 2) + .Package(url: "https://github.com/collinhundley/cmysql.git", majorVersion: 0, minor: 2) ] ) From d099306b34fe93068e28168528c225a69de48017 Mon Sep 17 00:00:00 2001 From: collinhundley Date: Tue, 2 Aug 2016 19:10:18 -0600 Subject: [PATCH 02/10] Add type accessors to --- Sources/MySQL/Value.swift | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Sources/MySQL/Value.swift b/Sources/MySQL/Value.swift index cdfcaf30..539ce9a4 100644 --- a/Sources/MySQL/Value.swift +++ b/Sources/MySQL/Value.swift @@ -8,4 +8,50 @@ public enum Value { case uint(UInt) case double(Double) case null + + public var string: String? { + switch self { + case let .string(val): + return val + default: + return nil + } + } + + public var int: Int? { + switch self { + case let .int(val): + return val + default: + return nil + } + } + + public var uint: UInt? { + switch self { + case let .uint(val): + return val + default: + return nil + } + } + + public var double: Double? { + switch self { + case let .double(val): + return val + default: + return nil + } + } + + public var isNull: Bool { + switch self { + case .null: + return true + default: + return false + } + } + } From 63028cbbc882454bf683446ffb6ebd723e915499 Mon Sep 17 00:00:00 2001 From: Collin Hundley Date: Tue, 2 Aug 2016 22:32:02 -0600 Subject: [PATCH 03/10] Update Package.swift --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 6b698c31..19e8d205 100644 --- a/Package.swift +++ b/Package.swift @@ -3,6 +3,6 @@ import PackageDescription let package = Package( name: "MySQL", dependencies: [ - .Package(url: "https://github.com/collinhundley/cmysql.git", majorVersion: 0, minor: 2) + .Package(url: "https://github.com/collinhundley/CMariaDB.git", majorVersion: 0, minor: 1) ] ) From 4a349db9e76489a3094f5cf1b36d49d4285b599b Mon Sep 17 00:00:00 2001 From: collinhundley Date: Mon, 8 Aug 2016 14:01:16 -0600 Subject: [PATCH 04/10] Change C dependency to collinhundley/CMariaDB --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index bb236fe6..358e4388 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ let package = Package( name: "MySQL", dependencies: [ // Module map for `libmysql` - .Package(url: "git@github.com:collinhundley/CMariaDB.git", majorVersion: 0), + .Package(url: "https://github.com/collinhundley/CMariaDB.git", majorVersion: 0), // Data structure for converting between multiple representations .Package(url: "https://github.com/vapor/node.git", majorVersion: 0, minor: 4), From c44dea67682b864b7ec7731dd7d7f5b452b81c25 Mon Sep 17 00:00:00 2001 From: collinhundley Date: Mon, 8 Aug 2016 15:42:12 -0600 Subject: [PATCH 05/10] MariaDB test --- Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 358e4388..4642d01e 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ let package = Package( name: "MySQL", dependencies: [ // Module map for `libmysql` - .Package(url: "https://github.com/collinhundley/CMariaDB.git", majorVersion: 0), + .Package(url: "https://github.com/collinhundley/cmysql.git", majorVersion: 0), // Data structure for converting between multiple representations .Package(url: "https://github.com/vapor/node.git", majorVersion: 0, minor: 4), From 6cf919812a5dbab2705c645c8b49d3282fdd52b3 Mon Sep 17 00:00:00 2001 From: collinhundley Date: Mon, 8 Aug 2016 15:57:08 -0600 Subject: [PATCH 06/10] Add MariaDB compiler flag --- Sources/MySQL/Bind+Node.swift | 4 ++++ Sources/MySQL/Bind.swift | 4 ++++ Sources/MySQL/Binds.swift | 4 ++++ Sources/MySQL/Connection.swift | 4 ++++ Sources/MySQL/Database.swift | 4 ++++ Sources/MySQL/Field+Variant.swift | 4 ++++ Sources/MySQL/Field.swift | 4 ++++ Sources/MySQL/Fields.swift | 4 ++++ 8 files changed, 32 insertions(+) diff --git a/Sources/MySQL/Bind+Node.swift b/Sources/MySQL/Bind+Node.swift index 2b5471e1..8a17007d 100644 --- a/Sources/MySQL/Bind+Node.swift +++ b/Sources/MySQL/Bind+Node.swift @@ -1,5 +1,9 @@ #if os(Linux) +#if MARIADB + import CMariaDBLinux +#else import CMySQLLinux +#endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Bind.swift b/Sources/MySQL/Bind.swift index ba0a8180..af9f4e62 100644 --- a/Sources/MySQL/Bind.swift +++ b/Sources/MySQL/Bind.swift @@ -2,7 +2,11 @@ import Core import JSON #if os(Linux) +#if MARIADB + import CMariaDBLinux +#else import CMySQLLinux +#endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Binds.swift b/Sources/MySQL/Binds.swift index 3c1ab857..aa522a5c 100644 --- a/Sources/MySQL/Binds.swift +++ b/Sources/MySQL/Binds.swift @@ -1,5 +1,9 @@ #if os(Linux) +#if MARIADB + import CMariaDBLinux +#else import CMySQLLinux +#endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Connection.swift b/Sources/MySQL/Connection.swift index 78405b6e..91e331a4 100644 --- a/Sources/MySQL/Connection.swift +++ b/Sources/MySQL/Connection.swift @@ -1,5 +1,9 @@ #if os(Linux) +#if MARIADB + import CMariaDBLinux +#else import CMySQLLinux +#endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Database.swift b/Sources/MySQL/Database.swift index b355349f..19d85489 100644 --- a/Sources/MySQL/Database.swift +++ b/Sources/MySQL/Database.swift @@ -1,5 +1,9 @@ #if os(Linux) +#if MARIADB + import CMariaDBLinux +#else import CMySQLLinux +#endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Field+Variant.swift b/Sources/MySQL/Field+Variant.swift index 9fe98ab9..c2adc6f0 100644 --- a/Sources/MySQL/Field+Variant.swift +++ b/Sources/MySQL/Field+Variant.swift @@ -1,5 +1,9 @@ #if os(Linux) +#if MARIADB + import CMariaDBLinux +#else import CMySQLLinux +#endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Field.swift b/Sources/MySQL/Field.swift index 540d02ac..811cf0a4 100644 --- a/Sources/MySQL/Field.swift +++ b/Sources/MySQL/Field.swift @@ -1,5 +1,9 @@ #if os(Linux) +#if MARIADB + import CMariaDBLinux +#else import CMySQLLinux +#endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Fields.swift b/Sources/MySQL/Fields.swift index 4af7a199..5186361d 100644 --- a/Sources/MySQL/Fields.swift +++ b/Sources/MySQL/Fields.swift @@ -1,5 +1,9 @@ #if os(Linux) +#if MARIADB + import CMariaDBLinux +#else import CMySQLLinux +#endif #else import CMySQLMac #endif From 14f3444631c494adb2a8140b5082c70c88c90a70 Mon Sep 17 00:00:00 2001 From: collinhundley Date: Mon, 8 Aug 2016 18:42:37 -0600 Subject: [PATCH 07/10] Change Char to UInt32 to prevent Unicode-related crash --- Sources/MySQL/Bind.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MySQL/Bind.swift b/Sources/MySQL/Bind.swift index af9f4e62..ea9d32aa 100644 --- a/Sources/MySQL/Bind.swift +++ b/Sources/MySQL/Bind.swift @@ -22,7 +22,7 @@ public final class Bind { public typealias CBind = MYSQL_BIND /// MySQL represents Characters using signed integers. - typealias Char = Int8 + typealias Char = UInt32 /** The raw C binding. From 198796daed51d53561ca23a40c392bcd4a9e5f27 Mon Sep 17 00:00:00 2001 From: collinhundley Date: Mon, 8 Aug 2016 23:40:39 -0600 Subject: [PATCH 08/10] Changed Char typealias to UInt8 --- Sources/MySQL/Bind.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MySQL/Bind.swift b/Sources/MySQL/Bind.swift index ea9d32aa..c1705caa 100644 --- a/Sources/MySQL/Bind.swift +++ b/Sources/MySQL/Bind.swift @@ -22,7 +22,7 @@ public final class Bind { public typealias CBind = MYSQL_BIND /// MySQL represents Characters using signed integers. - typealias Char = UInt32 + typealias Char = UInt8 /** The raw C binding. From c84ef00e8add372a88570013fc4c9a0ff0fc1ff1 Mon Sep 17 00:00:00 2001 From: collinhundley Date: Tue, 9 Aug 2016 00:11:55 -0600 Subject: [PATCH 09/10] Switch dependency to vapor/cmysql --- Package.swift | 2 +- Sources/MySQL/Bind+Node.swift | 10 +++++----- Sources/MySQL/Bind.swift | 10 +++++----- Sources/MySQL/Binds.swift | 10 +++++----- Sources/MySQL/Connection.swift | 10 +++++----- Sources/MySQL/Database.swift | 10 +++++----- Sources/MySQL/Field+Variant.swift | 10 +++++----- Sources/MySQL/Field.swift | 10 +++++----- Sources/MySQL/Fields.swift | 10 +++++----- 9 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Package.swift b/Package.swift index 4642d01e..30a1ffc8 100644 --- a/Package.swift +++ b/Package.swift @@ -4,7 +4,7 @@ let package = Package( name: "MySQL", dependencies: [ // Module map for `libmysql` - .Package(url: "https://github.com/collinhundley/cmysql.git", majorVersion: 0), + .Package(url: "https://github.com/vapor/cmysql.git", majorVersion: 0, minor: 2), // Data structure for converting between multiple representations .Package(url: "https://github.com/vapor/node.git", majorVersion: 0, minor: 4), diff --git a/Sources/MySQL/Bind+Node.swift b/Sources/MySQL/Bind+Node.swift index 8a17007d..ced57c6d 100644 --- a/Sources/MySQL/Bind+Node.swift +++ b/Sources/MySQL/Bind+Node.swift @@ -1,9 +1,9 @@ #if os(Linux) -#if MARIADB - import CMariaDBLinux -#else - import CMySQLLinux -#endif + #if MARIADB + import CMariaDBLinux + #else + import CMySQLLinux + #endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Bind.swift b/Sources/MySQL/Bind.swift index c1705caa..d003e441 100644 --- a/Sources/MySQL/Bind.swift +++ b/Sources/MySQL/Bind.swift @@ -2,11 +2,11 @@ import Core import JSON #if os(Linux) -#if MARIADB - import CMariaDBLinux -#else - import CMySQLLinux -#endif + #if MARIADB + import CMariaDBLinux + #else + import CMySQLLinux + #endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Binds.swift b/Sources/MySQL/Binds.swift index aa522a5c..bdedc5d1 100644 --- a/Sources/MySQL/Binds.swift +++ b/Sources/MySQL/Binds.swift @@ -1,9 +1,9 @@ #if os(Linux) -#if MARIADB - import CMariaDBLinux -#else - import CMySQLLinux -#endif + #if MARIADB + import CMariaDBLinux + #else + import CMySQLLinux + #endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Connection.swift b/Sources/MySQL/Connection.swift index 91e331a4..27a5cc4f 100644 --- a/Sources/MySQL/Connection.swift +++ b/Sources/MySQL/Connection.swift @@ -1,9 +1,9 @@ #if os(Linux) -#if MARIADB - import CMariaDBLinux -#else - import CMySQLLinux -#endif + #if MARIADB + import CMariaDBLinux + #else + import CMySQLLinux + #endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Database.swift b/Sources/MySQL/Database.swift index 19d85489..c596a930 100644 --- a/Sources/MySQL/Database.swift +++ b/Sources/MySQL/Database.swift @@ -1,9 +1,9 @@ #if os(Linux) -#if MARIADB - import CMariaDBLinux -#else - import CMySQLLinux -#endif + #if MARIADB + import CMariaDBLinux + #else + import CMySQLLinux + #endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Field+Variant.swift b/Sources/MySQL/Field+Variant.swift index c2adc6f0..601bfe47 100644 --- a/Sources/MySQL/Field+Variant.swift +++ b/Sources/MySQL/Field+Variant.swift @@ -1,9 +1,9 @@ #if os(Linux) -#if MARIADB - import CMariaDBLinux -#else - import CMySQLLinux -#endif + #if MARIADB + import CMariaDBLinux + #else + import CMySQLLinux + #endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Field.swift b/Sources/MySQL/Field.swift index 811cf0a4..18bdc49e 100644 --- a/Sources/MySQL/Field.swift +++ b/Sources/MySQL/Field.swift @@ -1,9 +1,9 @@ #if os(Linux) -#if MARIADB - import CMariaDBLinux -#else - import CMySQLLinux -#endif + #if MARIADB + import CMariaDBLinux + #else + import CMySQLLinux + #endif #else import CMySQLMac #endif diff --git a/Sources/MySQL/Fields.swift b/Sources/MySQL/Fields.swift index 5186361d..bbdbd05d 100644 --- a/Sources/MySQL/Fields.swift +++ b/Sources/MySQL/Fields.swift @@ -1,9 +1,9 @@ #if os(Linux) -#if MARIADB - import CMariaDBLinux -#else - import CMySQLLinux -#endif + #if MARIADB + import CMariaDBLinux + #else + import CMySQLLinux + #endif #else import CMySQLMac #endif From 4f4e71e9f871e8da147eebdcabd863125ea2dc75 Mon Sep 17 00:00:00 2001 From: collinhundley Date: Tue, 9 Aug 2016 13:59:38 -0600 Subject: [PATCH 10/10] Updated comment for Char --- Sources/MySQL/Bind.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MySQL/Bind.swift b/Sources/MySQL/Bind.swift index d003e441..8d2cbcbe 100644 --- a/Sources/MySQL/Bind.swift +++ b/Sources/MySQL/Bind.swift @@ -21,7 +21,7 @@ import JSON public final class Bind { public typealias CBind = MYSQL_BIND - /// MySQL represents Characters using signed integers. + /// UTF-8 stores characters using 1-4 bytes, represented in Swift as unsigned integers. typealias Char = UInt8 /**