@@ -62,10 +62,6 @@ mod rdbms_types {
6262 spin:: postgres:: postgres:: DbValue :: Int16 ( i) => v1:: rdbms_types:: DbValue :: Int16 ( i) ,
6363 spin:: postgres:: postgres:: DbValue :: Int32 ( i) => v1:: rdbms_types:: DbValue :: Int32 ( i) ,
6464 spin:: postgres:: postgres:: DbValue :: Int64 ( i) => v1:: rdbms_types:: DbValue :: Int64 ( i) ,
65- spin:: postgres:: postgres:: DbValue :: Uint8 ( j) => v1:: rdbms_types:: DbValue :: Uint8 ( j) ,
66- spin:: postgres:: postgres:: DbValue :: Uint16 ( u) => v1:: rdbms_types:: DbValue :: Uint16 ( u) ,
67- spin:: postgres:: postgres:: DbValue :: Uint32 ( u) => v1:: rdbms_types:: DbValue :: Uint32 ( u) ,
68- spin:: postgres:: postgres:: DbValue :: Uint64 ( u) => v1:: rdbms_types:: DbValue :: Uint64 ( u) ,
6965 spin:: postgres:: postgres:: DbValue :: Floating32 ( r) => {
7066 v1:: rdbms_types:: DbValue :: Floating32 ( r)
7167 }
@@ -93,10 +89,6 @@ mod rdbms_types {
9389 spin:: postgres:: postgres:: DbValue :: Int16 ( i) => v2:: rdbms_types:: DbValue :: Int16 ( i) ,
9490 spin:: postgres:: postgres:: DbValue :: Int32 ( i) => v2:: rdbms_types:: DbValue :: Int32 ( i) ,
9591 spin:: postgres:: postgres:: DbValue :: Int64 ( i) => v2:: rdbms_types:: DbValue :: Int64 ( i) ,
96- spin:: postgres:: postgres:: DbValue :: Uint8 ( j) => v2:: rdbms_types:: DbValue :: Uint8 ( j) ,
97- spin:: postgres:: postgres:: DbValue :: Uint16 ( u) => v2:: rdbms_types:: DbValue :: Uint16 ( u) ,
98- spin:: postgres:: postgres:: DbValue :: Uint32 ( u) => v2:: rdbms_types:: DbValue :: Uint32 ( u) ,
99- spin:: postgres:: postgres:: DbValue :: Uint64 ( u) => v2:: rdbms_types:: DbValue :: Uint64 ( u) ,
10092 spin:: postgres:: postgres:: DbValue :: Floating32 ( r) => {
10193 v2:: rdbms_types:: DbValue :: Floating32 ( r)
10294 }
@@ -124,10 +116,6 @@ mod rdbms_types {
124116 spin:: postgres:: postgres:: DbDataType :: Int16 => v1:: rdbms_types:: DbDataType :: Int16 ,
125117 spin:: postgres:: postgres:: DbDataType :: Int32 => v1:: rdbms_types:: DbDataType :: Int32 ,
126118 spin:: postgres:: postgres:: DbDataType :: Int64 => v1:: rdbms_types:: DbDataType :: Int64 ,
127- spin:: postgres:: postgres:: DbDataType :: Uint8 => v1:: rdbms_types:: DbDataType :: Uint8 ,
128- spin:: postgres:: postgres:: DbDataType :: Uint16 => v1:: rdbms_types:: DbDataType :: Uint16 ,
129- spin:: postgres:: postgres:: DbDataType :: Uint32 => v1:: rdbms_types:: DbDataType :: Uint32 ,
130- spin:: postgres:: postgres:: DbDataType :: Uint64 => v1:: rdbms_types:: DbDataType :: Uint64 ,
131119 spin:: postgres:: postgres:: DbDataType :: Floating32 => {
132120 v1:: rdbms_types:: DbDataType :: Floating32
133121 }
@@ -152,10 +140,6 @@ mod rdbms_types {
152140 spin:: postgres:: postgres:: DbDataType :: Int16 => v2:: rdbms_types:: DbDataType :: Int16 ,
153141 spin:: postgres:: postgres:: DbDataType :: Int32 => v2:: rdbms_types:: DbDataType :: Int32 ,
154142 spin:: postgres:: postgres:: DbDataType :: Int64 => v2:: rdbms_types:: DbDataType :: Int64 ,
155- spin:: postgres:: postgres:: DbDataType :: Uint8 => v2:: rdbms_types:: DbDataType :: Uint8 ,
156- spin:: postgres:: postgres:: DbDataType :: Uint16 => v2:: rdbms_types:: DbDataType :: Uint16 ,
157- spin:: postgres:: postgres:: DbDataType :: Uint32 => v2:: rdbms_types:: DbDataType :: Uint32 ,
158- spin:: postgres:: postgres:: DbDataType :: Uint64 => v2:: rdbms_types:: DbDataType :: Uint64 ,
159143 spin:: postgres:: postgres:: DbDataType :: Floating32 => {
160144 v2:: rdbms_types:: DbDataType :: Floating32
161145 }
@@ -236,11 +220,13 @@ mod rdbms_types {
236220 }
237221 }
238222
239- impl From < v1:: rdbms_types:: ParameterValue > for spin:: postgres:: postgres:: ParameterValue {
240- fn from (
223+ impl TryFrom < v1:: rdbms_types:: ParameterValue > for spin:: postgres:: postgres:: ParameterValue {
224+ type Error = v1:: postgres:: PgError ;
225+
226+ fn try_from (
241227 value : v1:: rdbms_types:: ParameterValue ,
242- ) -> spin:: postgres:: postgres:: ParameterValue {
243- match value {
228+ ) -> Result < spin:: postgres:: postgres:: ParameterValue , Self :: Error > {
229+ let converted = match value {
244230 v1:: rdbms_types:: ParameterValue :: Boolean ( b) => {
245231 spin:: postgres:: postgres:: ParameterValue :: Boolean ( b)
246232 }
@@ -256,17 +242,13 @@ mod rdbms_types {
256242 v1:: rdbms_types:: ParameterValue :: Int64 ( i) => {
257243 spin:: postgres:: postgres:: ParameterValue :: Int64 ( i)
258244 }
259- v1:: rdbms_types:: ParameterValue :: Uint8 ( u) => {
260- spin:: postgres:: postgres:: ParameterValue :: Uint8 ( u)
261- }
262- v1:: rdbms_types:: ParameterValue :: Uint16 ( u) => {
263- spin:: postgres:: postgres:: ParameterValue :: Uint16 ( u)
264- }
265- v1:: rdbms_types:: ParameterValue :: Uint32 ( u) => {
266- spin:: postgres:: postgres:: ParameterValue :: Uint32 ( u)
267- }
268- v1:: rdbms_types:: ParameterValue :: Uint64 ( u) => {
269- spin:: postgres:: postgres:: ParameterValue :: Uint64 ( u)
245+ v1:: rdbms_types:: ParameterValue :: Uint8 ( _)
246+ | v1:: rdbms_types:: ParameterValue :: Uint16 ( _)
247+ | v1:: rdbms_types:: ParameterValue :: Uint32 ( _)
248+ | v1:: rdbms_types:: ParameterValue :: Uint64 ( _) => {
249+ return Err ( v1:: postgres:: PgError :: ValueConversionFailed (
250+ "Postgres does not support unsigned integers" . to_owned ( ) ,
251+ ) ) ;
270252 }
271253 v1:: rdbms_types:: ParameterValue :: Floating32 ( r) => {
272254 spin:: postgres:: postgres:: ParameterValue :: Floating32 ( r)
@@ -283,15 +265,18 @@ mod rdbms_types {
283265 v1:: rdbms_types:: ParameterValue :: DbNull => {
284266 spin:: postgres:: postgres:: ParameterValue :: DbNull
285267 }
286- }
268+ } ;
269+ Ok ( converted)
287270 }
288271 }
289272
290- impl From < v2:: rdbms_types:: ParameterValue > for spin:: postgres:: postgres:: ParameterValue {
291- fn from (
273+ impl TryFrom < v2:: rdbms_types:: ParameterValue > for spin:: postgres:: postgres:: ParameterValue {
274+ type Error = v2:: rdbms_types:: Error ;
275+
276+ fn try_from (
292277 value : v2:: rdbms_types:: ParameterValue ,
293- ) -> spin:: postgres:: postgres:: ParameterValue {
294- match value {
278+ ) -> Result < spin:: postgres:: postgres:: ParameterValue , Self :: Error > {
279+ let converted = match value {
295280 v2:: rdbms_types:: ParameterValue :: Boolean ( b) => {
296281 spin:: postgres:: postgres:: ParameterValue :: Boolean ( b)
297282 }
@@ -307,17 +292,13 @@ mod rdbms_types {
307292 v2:: rdbms_types:: ParameterValue :: Int64 ( i) => {
308293 spin:: postgres:: postgres:: ParameterValue :: Int64 ( i)
309294 }
310- v2:: rdbms_types:: ParameterValue :: Uint8 ( u) => {
311- spin:: postgres:: postgres:: ParameterValue :: Uint8 ( u)
312- }
313- v2:: rdbms_types:: ParameterValue :: Uint16 ( u) => {
314- spin:: postgres:: postgres:: ParameterValue :: Uint16 ( u)
315- }
316- v2:: rdbms_types:: ParameterValue :: Uint32 ( u) => {
317- spin:: postgres:: postgres:: ParameterValue :: Uint32 ( u)
318- }
319- v2:: rdbms_types:: ParameterValue :: Uint64 ( u) => {
320- spin:: postgres:: postgres:: ParameterValue :: Uint64 ( u)
295+ v2:: rdbms_types:: ParameterValue :: Uint8 ( _)
296+ | v2:: rdbms_types:: ParameterValue :: Uint16 ( _)
297+ | v2:: rdbms_types:: ParameterValue :: Uint32 ( _)
298+ | v2:: rdbms_types:: ParameterValue :: Uint64 ( _) => {
299+ return Err ( v2:: rdbms_types:: Error :: ValueConversionFailed (
300+ "Postgres does not support unsigned integers" . to_owned ( ) ,
301+ ) ) ;
321302 }
322303 v2:: rdbms_types:: ParameterValue :: Floating32 ( r) => {
323304 spin:: postgres:: postgres:: ParameterValue :: Floating32 ( r)
@@ -334,7 +315,8 @@ mod rdbms_types {
334315 v2:: rdbms_types:: ParameterValue :: DbNull => {
335316 spin:: postgres:: postgres:: ParameterValue :: DbNull
336317 }
337- }
318+ } ;
319+ Ok ( converted)
338320 }
339321 }
340322
0 commit comments