@@ -89,19 +89,47 @@ extension PostgresCell {
89
89
func toSQLValue( ) throws -> SQLValue {
90
90
switch dataType {
91
91
case . int2, . int4, . int8:
92
- return . int( try decode ( Int . self, context: . default) )
92
+ guard let int = try decode ( Int ? . self, context: . default) else {
93
+ return . null
94
+ }
95
+
96
+ return . int( int)
93
97
case . bool:
94
- return . bool( try decode ( Bool . self, context: . default) )
98
+ guard let bool = try decode ( Bool ? . self, context: . default) else {
99
+ return . null
100
+ }
101
+
102
+ return . bool( bool)
95
103
case . varchar, . text:
96
- return . string( try decode ( String . self, context: . default) )
104
+ guard let str = try decode ( String ? . self, context: . default) else {
105
+ return . null
106
+ }
107
+
108
+ return . string( str)
97
109
case . date, . timestamptz, . timestamp:
98
- return . date( try decode ( Date . self, context: . default) )
110
+ guard let date = try decode ( Date ? . self, context: . default) else {
111
+ return . null
112
+ }
113
+
114
+ return . date( date)
99
115
case . float4, . float8:
100
- return . double( try decode ( Double . self, context: . default) )
116
+ guard let double = try decode ( Double ? . self, context: . default) else {
117
+ return . null
118
+ }
119
+
120
+ return . double( double)
101
121
case . uuid:
102
- return . uuid( try decode ( UUID . self, context: . default) )
122
+ guard let uuid = try decode ( UUID ? . self, context: . default) else {
123
+ return . null
124
+ }
125
+
126
+ return . uuid( uuid)
103
127
case . json, . jsonb:
104
- return . json( try decode ( Data . self, context: . default) )
128
+ guard let json = try decode ( Data ? . self, context: . default) else {
129
+ return . null
130
+ }
131
+
132
+ return . json( json)
105
133
case . null:
106
134
return . null
107
135
default :
0 commit comments