-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from vapor/cc-fixes
conditional conformance fixes
- Loading branch information
Showing
4 changed files
with
74 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,32 @@ | ||
import Async | ||
import Foundation | ||
|
||
extension OptionalType where Self.WrappedType: PostgreSQLDataCustomConvertible { | ||
extension OptionalType { | ||
/// See `PostgreSQLDataCustomConvertible.convertFromPostgreSQLData(_:)` | ||
public static func convertFromPostgreSQLData(_ data: PostgreSQLData) throws -> Self { | ||
let wrapped = try WrappedType.convertFromPostgreSQLData(data) | ||
return Self.makeOptionalType(wrapped) | ||
let wrapped = try requirePostgreSQLDataCustomConvertible(WrappedType.self).convertFromPostgreSQLData(data) | ||
return Self.makeOptionalType(wrapped as? WrappedType) | ||
} | ||
|
||
/// See `PostgreSQLDataCustomConvertible.convertToPostgreSQLData()` | ||
public func convertToPostgreSQLData() throws -> PostgreSQLData { | ||
if let wrapped = self.wrapped { | ||
return try wrapped.convertToPostgreSQLData() | ||
return try requirePostgreSQLDataCustomConvertible(wrapped).convertToPostgreSQLData() | ||
} else { | ||
return PostgreSQLData(type: .void, format: .binary, data: nil) | ||
} | ||
} | ||
} | ||
|
||
extension Optional: PostgreSQLDataCustomConvertible where Wrapped: PostgreSQLDataCustomConvertible { | ||
extension Optional: PostgreSQLDataCustomConvertible { | ||
/// See `PostgreSQLDataCustomConvertible.postgreSQLDataType` | ||
public static var postgreSQLDataType: PostgreSQLDataType { | ||
return Wrapped.postgreSQLDataType | ||
return requirePostgreSQLDataCustomConvertible(Wrapped.self).postgreSQLDataType | ||
} | ||
|
||
|
||
/// See `PostgreSQLDataCustomConvertible.postgreSQLDataArrayType` | ||
public static var postgreSQLDataArrayType: PostgreSQLDataType { | ||
return Wrapped.postgreSQLDataArrayType | ||
return requirePostgreSQLDataCustomConvertible(Wrapped.self).postgreSQLDataArrayType | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters