Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
123FLO321 committed Aug 2, 2020
1 parent c7f0b5c commit a168662
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
43 changes: 19 additions & 24 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
// swift-tools-version:4.0
// Package.swift
// Perfect-MySQL
//
// Created by Kyle Jessup on 3/22/16.
// Copyright (C) 2016 PerfectlySoft, Inc.
//
//===----------------------------------------------------------------------===//
//
// This source file is part of the Perfect.org open source project
//
// Copyright (c) 2015 - 2016 PerfectlySoft Inc. and the Perfect project authors
// Licensed under Apache License v2.0
//
// See http://perfect.org/licensing.html for license information
//
//===----------------------------------------------------------------------===//
//
// swift-tools-version:5.2

import PackageDescription


#if os(macOS)
let clientPackage = "Perfect-mysqlclient"
let mysqlclientPath = "Sources/mysqlclient-macos"
#else
let clientPackage = "Perfect-mysqlclient-Linux"
let mysqlclientPath = "Sources/mysqlclient"
#endif

let package = Package(
name: "PerfectMySQL",
platforms: [
.macOS(.v10_15)
],
products: [
.library(name: "PerfectMySQL", targets: ["PerfectMySQL"])
],
dependencies: [
.package(url: "https://github.com/PerfectlySoft/Perfect-CRUD.git", from: "1.2.2"),
.package(url: "https://github.com/PerfectlySoft/\(clientPackage).git", from: "2.0.0"),
],
.package(name: "PerfectCRUD", url: "https://github.com/123FLO321/Perfect-CRUD.git", .branch("swift5"))
],
targets: [
.target(name: "PerfectMySQL", dependencies: ["PerfectCRUD"]),
.systemLibrary(
name: "mysqlclient",
path: mysqlclientPath,
pkgConfig: "mysqlclient",
providers: [
.brew(["mysql"]),
.apt(["libmysqlclient-dev"]),
]
),
.target(name: "PerfectMySQL", dependencies: ["PerfectCRUD", "mysqlclient"]),
.testTarget(name: "PerfectMySQLTests", dependencies: ["PerfectMySQL"])
]
)
10 changes: 7 additions & 3 deletions Sources/PerfectMySQL/MySQLCRUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class MySQLCRUDRowReader<K : CodingKey>: KeyedDecodingContainerProtocol {
return ret as! T
case .data:
let bytes: [UInt8] = (val as? [UInt8]) ?? []
return Data(bytes: bytes) as! T
return Data(bytes) as! T
case .uuid:
guard let str = val as? String, let uuid = UUID(uuidString: str) else {
throw CRUDDecoderError("Invalid UUID string \(String(describing: val)).")
Expand All @@ -155,7 +155,9 @@ class MySQLCRUDRowReader<K : CodingKey>: KeyedDecodingContainerProtocol {
throw CRUDDecoderError("Unsupported type: \(type) for key: \(key.stringValue)")
}
return try JSONDecoder().decode(type, from: data)
}
case .wrapped:
throw CRUDDecoderError("Wrapped is unsupported.")
}
}
func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type, forKey key: Key) throws -> KeyedDecodingContainer<NestedKey> where NestedKey : CodingKey {
throw CRUDDecoderError("Unimplimented nestedContainer")
Expand Down Expand Up @@ -339,7 +341,9 @@ class MySQLGenDelegate: SQLGenDelegate {
typeName = "longtext"
case .codable:
typeName = "json"
}
case .wrapped:
throw MySQLCRUDError("Wrapped is unsupported.")
}
}
let addendum: String
if column.properties.contains(.primaryKey) {
Expand Down
5 changes: 5 additions & 0 deletions Sources/mysqlclient-macos/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module mysqlclient {
header "/usr/local/include/mysql/mysql.h"
link "mysqlclient"
export *
}
5 changes: 5 additions & 0 deletions Sources/mysqlclient/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module mysqlclient {
header "/usr/include/mysql/mysql.h"
link "mysqlclient"
export *
}

0 comments on commit a168662

Please sign in to comment.