1- import Foundation
2-
31/// A PostgreSQL column type and size.
42public struct PostgreSQLColumn {
53 /// The columns data type.
@@ -23,67 +21,3 @@ public protocol PostgreSQLColumnStaticRepresentable {
2321 static var postgreSQLColumn : PostgreSQLColumn { get }
2422}
2523
26- /// MARK: Default Implementations
27-
28- extension Data : PostgreSQLColumnStaticRepresentable {
29- /// See `PostgreSQLColumnStaticRepresentable.postgreSQLColumn`
30- public static var postgreSQLColumn : PostgreSQLColumn { return . init( type: . bytea) }
31- }
32-
33- extension UUID : PostgreSQLColumnStaticRepresentable {
34- /// See `PostgreSQLColumnStaticRepresentable.postgreSQLColumn`
35- public static var postgreSQLColumn : PostgreSQLColumn { return . init( type: . uuid) }
36- }
37-
38- extension Date : PostgreSQLColumnStaticRepresentable {
39- /// See `PostgreSQLColumnStaticRepresentable.postgreSQLColumn`
40- public static var postgreSQLColumn : PostgreSQLColumn { return . init( type: . timestamp) }
41- }
42-
43- extension FixedWidthInteger {
44- /// See `PostgreSQLColumnStaticRepresentable.postgreSQLColumn`
45- public static var postgreSQLColumn : PostgreSQLColumn {
46- switch bitWidth {
47- case 64 : return . init( type: . int8)
48- case 32 : return . init( type: . int4)
49- case 16 : return . init( type: . int2)
50- case 8 : return . init( type: . char)
51- default : fatalError ( " Unexpected \( Self . self) bit width: \( bitWidth) " )
52- }
53- }
54- }
55-
56- extension Int : PostgreSQLColumnStaticRepresentable { }
57- extension Int8 : PostgreSQLColumnStaticRepresentable { }
58- extension Int16 : PostgreSQLColumnStaticRepresentable { }
59- extension Int32 : PostgreSQLColumnStaticRepresentable { }
60- extension Int64 : PostgreSQLColumnStaticRepresentable { }
61- extension UInt : PostgreSQLColumnStaticRepresentable { }
62- extension UInt8 : PostgreSQLColumnStaticRepresentable { }
63- extension UInt16 : PostgreSQLColumnStaticRepresentable { }
64- extension UInt32 : PostgreSQLColumnStaticRepresentable { }
65- extension UInt64 : PostgreSQLColumnStaticRepresentable { }
66-
67- extension BinaryFloatingPoint {
68- /// See `PostgreSQLColumnStaticRepresentable.postgreSQLColumn`
69- public static var postgreSQLColumn : PostgreSQLColumn {
70- switch exponentBitCount + significandBitCount + 1 {
71- case 64 : return . init( type: . float8)
72- case 32 : return . init( type: . float4)
73- default : fatalError ( " Unexpected \( Self . self) bit width: \( exponentBitCount + significandBitCount + 1 ) " )
74- }
75- }
76- }
77-
78- extension Float : PostgreSQLColumnStaticRepresentable { }
79- extension Double : PostgreSQLColumnStaticRepresentable { }
80-
81- extension String : PostgreSQLColumnStaticRepresentable {
82- /// See `PostgreSQLColumnStaticRepresentable.postgreSQLColumn`
83- public static var postgreSQLColumn : PostgreSQLColumn { return . init( type: . text) }
84- }
85-
86- extension Bool : PostgreSQLColumnStaticRepresentable {
87- /// See `PostgreSQLColumnStaticRepresentable.postgreSQLColumn`
88- public static var postgreSQLColumn : PostgreSQLColumn { return . init( type: . bool) }
89- }
0 commit comments