This repository has been archived by the owner on Mar 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
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 #2 from codynhat/master
Uses Node instead of PostgreSQL.Value
- Loading branch information
Showing
10 changed files
with
66 additions
and
104 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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#if os(Linux) | ||
import CPostgreSQLLinux | ||
#else | ||
import CPostgreSQLMac | ||
#endif | ||
|
||
public enum OID: Oid { | ||
case text = 25 | ||
case varchar = 1043 | ||
case int2 = 21 | ||
case int4 = 23 | ||
case int8 = 20 | ||
case float4 = 700 | ||
case float8 = 701 | ||
case numeric = 1700 | ||
case bool = 16 | ||
case char = 18 | ||
case unknown = 705 | ||
} | ||
|
||
extension Node { | ||
init(oid: Oid, value: String) { | ||
guard let type = OID(rawValue: oid) else { | ||
self = .null | ||
return | ||
} | ||
|
||
switch type { | ||
case .text, .varchar, .char: | ||
self = .string(value) | ||
case .int2, .int4, .int8: | ||
self = .number(.int(Int(value) ?? 0)) | ||
case .float4, .float8, .numeric: | ||
self = .number(.double(Double(value) ?? 0)) | ||
case .bool: | ||
self = .bool((value == "true") ? true : false) | ||
case .unknown: | ||
self = .null | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
@_exported import Node |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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