Skip to content

Commit bbd0e70

Browse files
authored
Enum Support (#253)
* enum support * enum
1 parent 247ed00 commit bbd0e70

File tree

3 files changed

+43
-19
lines changed

3 files changed

+43
-19
lines changed

Sources/MySQLKit/MySQLDatabase.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,12 @@ public struct MySQLDialect: SQLDialect {
158158
public var autoIncrementClause: SQLExpression {
159159
return SQLRaw("AUTO_INCREMENT")
160160
}
161+
162+
public var supportsAutoIncrement: Bool {
163+
true
164+
}
165+
166+
public var enumSyntax: SQLEnumSyntax {
167+
.inline
168+
}
161169
}
Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
1+
import Logging
12
import MySQLKit
23
import SQLKitBenchmark
34
import XCTest
45

56
class MySQLKitTests: XCTestCase {
6-
private var group: EventLoopGroup!
7-
private var eventLoop: EventLoop {
8-
return self.group.next()
7+
func testEnum() throws {
8+
try self.benchmark.testEnum()
99
}
10-
10+
11+
var db: SQLDatabase {
12+
self.connection.sql()
13+
}
14+
var benchmark: SQLBenchmarker {
15+
.init(on: self.db)
16+
}
17+
18+
var eventLoopGroup: EventLoopGroup!
19+
var connection: MySQLConnection!
20+
1121
override func setUp() {
12-
self.group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
22+
XCTAssertTrue(isLoggingConfigured)
23+
self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 2)
24+
self.connection = try! MySQLConnection.test(
25+
on: self.eventLoopGroup.next()
26+
).wait()
1327
}
14-
28+
1529
override func tearDown() {
16-
XCTAssertNoThrow(try self.group.syncShutdownGracefully())
17-
self.group = nil
18-
}
19-
20-
21-
func testSQLKitBenchmark() throws {
22-
let conn = try MySQLConnection.test(on: self.eventLoop).wait()
23-
defer { try! conn.close().wait() }
24-
let benchmark = SQLBenchmarker(on: conn.sql())
25-
print(benchmark)
26-
// try benchmark.run()
30+
try! self.connection.close().wait()
31+
self.connection = nil
32+
try! self.eventLoopGroup.syncShutdownGracefully()
33+
self.eventLoopGroup = nil
2734
}
2835
}
2936

@@ -47,3 +54,12 @@ extension MySQLConnection {
4754
func env(_ name: String) -> String? {
4855
getenv(name).flatMap { String(cString: $0) }
4956
}
57+
58+
let isLoggingConfigured: Bool = {
59+
LoggingSystem.bootstrap { label in
60+
var handler = StreamLogHandler.standardOutput(label: label)
61+
handler.logLevel = .debug
62+
return handler
63+
}
64+
return true
65+
}()

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '3'
22

33
services:
4-
mysql-8_0:
4+
mysql-8:
55
image: mysql:8.0
66
environment:
77
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
@@ -10,7 +10,7 @@ services:
1010
MYSQL_PASSWORD: vapor_password
1111
ports:
1212
- 3306:3306
13-
mysql-5_7:
13+
mysql-5:
1414
image: mysql:5.7
1515
environment:
1616
MYSQL_ALLOW_EMPTY_PASSWORD: "true"

0 commit comments

Comments
 (0)