@@ -31,12 +31,12 @@ extension UInt8: PostgresDecodable {
31
31
switch type {
32
32
case . bpchar, . char:
33
33
guard buffer. readableBytes == 1 , let value = buffer. readInteger ( as: UInt8 . self) else {
34
- throw PostgresCastingError . Code. failure
34
+ throw PostgresDecodingError . Code. failure
35
35
}
36
36
37
37
self = value
38
38
default :
39
- throw PostgresCastingError . Code. typeMismatch
39
+ throw PostgresDecodingError . Code. typeMismatch
40
40
}
41
41
}
42
42
}
@@ -74,16 +74,16 @@ extension Int16: PostgresDecodable {
74
74
switch ( format, type) {
75
75
case ( . binary, . int2) :
76
76
guard buffer. readableBytes == 2 , let value = buffer. readInteger ( as: Int16 . self) else {
77
- throw PostgresCastingError . Code. failure
77
+ throw PostgresDecodingError . Code. failure
78
78
}
79
79
self = value
80
80
case ( . text, . int2) :
81
81
guard let string = buffer. readString ( length: buffer. readableBytes) , let value = Int16 ( string) else {
82
- throw PostgresCastingError . Code. failure
82
+ throw PostgresDecodingError . Code. failure
83
83
}
84
84
self = value
85
85
default :
86
- throw PostgresCastingError . Code. typeMismatch
86
+ throw PostgresDecodingError . Code. typeMismatch
87
87
}
88
88
}
89
89
}
@@ -96,7 +96,7 @@ extension Int32: PostgresEncodable {
96
96
public static var psqlType : PostgresDataType {
97
97
. int4
98
98
}
99
-
99
+
100
100
public static var psqlFormat : PostgresFormat {
101
101
. binary
102
102
}
@@ -121,21 +121,21 @@ extension Int32: PostgresDecodable {
121
121
switch ( format, type) {
122
122
case ( . binary, . int2) :
123
123
guard buffer. readableBytes == 2 , let value = buffer. readInteger ( as: Int16 . self) else {
124
- throw PostgresCastingError . Code. failure
124
+ throw PostgresDecodingError . Code. failure
125
125
}
126
126
self = Int32 ( value)
127
127
case ( . binary, . int4) :
128
128
guard buffer. readableBytes == 4 , let value = buffer. readInteger ( as: Int32 . self) else {
129
- throw PostgresCastingError . Code. failure
129
+ throw PostgresDecodingError . Code. failure
130
130
}
131
131
self = Int32 ( value)
132
132
case ( . text, . int2) , ( . text, . int4) :
133
133
guard let string = buffer. readString ( length: buffer. readableBytes) , let value = Int32 ( string) else {
134
- throw PostgresCastingError . Code. failure
134
+ throw PostgresDecodingError . Code. failure
135
135
}
136
136
self = value
137
137
default :
138
- throw PostgresCastingError . Code. typeMismatch
138
+ throw PostgresDecodingError . Code. typeMismatch
139
139
}
140
140
}
141
141
}
@@ -173,26 +173,26 @@ extension Int64: PostgresDecodable {
173
173
switch ( format, type) {
174
174
case ( . binary, . int2) :
175
175
guard buffer. readableBytes == 2 , let value = buffer. readInteger ( as: Int16 . self) else {
176
- throw PostgresCastingError . Code. failure
176
+ throw PostgresDecodingError . Code. failure
177
177
}
178
178
self = Int64 ( value)
179
179
case ( . binary, . int4) :
180
180
guard buffer. readableBytes == 4 , let value = buffer. readInteger ( as: Int32 . self) else {
181
- throw PostgresCastingError . Code. failure
181
+ throw PostgresDecodingError . Code. failure
182
182
}
183
183
self = Int64 ( value)
184
184
case ( . binary, . int8) :
185
185
guard buffer. readableBytes == 8 , let value = buffer. readInteger ( as: Int64 . self) else {
186
- throw PostgresCastingError . Code. failure
186
+ throw PostgresDecodingError . Code. failure
187
187
}
188
188
self = value
189
189
case ( . text, . int2) , ( . text, . int4) , ( . text, . int8) :
190
190
guard let string = buffer. readString ( length: buffer. readableBytes) , let value = Int64 ( string) else {
191
- throw PostgresCastingError . Code. failure
191
+ throw PostgresDecodingError . Code. failure
192
192
}
193
193
self = value
194
194
default :
195
- throw PostgresCastingError . Code. typeMismatch
195
+ throw PostgresDecodingError . Code. typeMismatch
196
196
}
197
197
}
198
198
}
@@ -212,7 +212,7 @@ extension Int: PostgresEncodable {
212
212
preconditionFailure ( " Int is expected to be an Int32 or Int64 " )
213
213
}
214
214
}
215
-
215
+
216
216
public static var psqlFormat : PostgresFormat {
217
217
. binary
218
218
}
@@ -237,26 +237,26 @@ extension Int: PostgresDecodable {
237
237
switch ( format, type) {
238
238
case ( . binary, . int2) :
239
239
guard buffer. readableBytes == 2 , let value = buffer. readInteger ( as: Int16 . self) else {
240
- throw PostgresCastingError . Code. failure
240
+ throw PostgresDecodingError . Code. failure
241
241
}
242
242
self = Int ( value)
243
243
case ( . binary, . int4) :
244
244
guard buffer. readableBytes == 4 , let value = buffer. readInteger ( as: Int32 . self) . flatMap ( { Int ( exactly: $0) } ) else {
245
- throw PostgresCastingError . Code. failure
245
+ throw PostgresDecodingError . Code. failure
246
246
}
247
247
self = value
248
248
case ( . binary, . int8) :
249
249
guard buffer. readableBytes == 8 , let value = buffer. readInteger ( as: Int . self) . flatMap ( { Int ( exactly: $0) } ) else {
250
- throw PostgresCastingError . Code. failure
250
+ throw PostgresDecodingError . Code. failure
251
251
}
252
252
self = value
253
253
case ( . text, . int2) , ( . text, . int4) , ( . text, . int8) :
254
254
guard let string = buffer. readString ( length: buffer. readableBytes) , let value = Int ( string) else {
255
- throw PostgresCastingError . Code. failure
255
+ throw PostgresDecodingError . Code. failure
256
256
}
257
257
self = value
258
258
default :
259
- throw PostgresCastingError . Code. typeMismatch
259
+ throw PostgresDecodingError . Code. typeMismatch
260
260
}
261
261
}
262
262
}
0 commit comments