Skip to content

Commit e7f11ed

Browse files
Update postgresql_type.go
Check notNull and emitPointersForNull before checking postgres driver
1 parent ec9d492 commit e7f11ed

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

internal/codegen/golang/postgresql_type.go

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,16 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
213213
return "sql.NullTime"
214214

215215
case "pg_catalog.time":
216-
if driver == opts.SQLDriverPGXV5 {
217-
return "pgtype.Time"
218-
}
219216
if notNull {
220217
return "time.Time"
221218
}
222219
if emitPointersForNull {
223220
return "*time.Time"
224221
}
222+
if driver == opts.SQLDriverPGXV5 {
223+
return "pgtype.Time"
224+
}
225+
225226
return "sql.NullTime"
226227

227228
case "pg_catalog.timetz":
@@ -234,27 +235,29 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
234235
return "sql.NullTime"
235236

236237
case "pg_catalog.timestamp", "timestamp":
237-
if driver == opts.SQLDriverPGXV5 {
238-
return "pgtype.Timestamp"
239-
}
240238
if notNull {
241239
return "time.Time"
242240
}
243241
if emitPointersForNull {
244242
return "*time.Time"
245243
}
244+
if driver == opts.SQLDriverPGXV5 {
245+
return "pgtype.Timestamp"
246+
}
247+
246248
return "sql.NullTime"
247249

248250
case "pg_catalog.timestamptz", "timestamptz":
249-
if driver == opts.SQLDriverPGXV5 {
250-
return "pgtype.Timestamptz"
251-
}
252251
if notNull {
253252
return "time.Time"
254253
}
255254
if emitPointersForNull {
256255
return "*time.Time"
257256
}
257+
if driver == opts.SQLDriverPGXV5 {
258+
return "pgtype.Timestamptz"
259+
}
260+
258261
return "sql.NullTime"
259262

260263
case "text", "pg_catalog.varchar", "pg_catalog.bpchar", "string", "citext", "name":
@@ -270,15 +273,16 @@ func postgresType(req *plugin.GenerateRequest, options *opts.Options, col *plugi
270273
return "sql.NullString"
271274

272275
case "uuid":
273-
if driver == opts.SQLDriverPGXV5 {
274-
return "pgtype.UUID"
275-
}
276276
if notNull {
277277
return "uuid.UUID"
278278
}
279279
if emitPointersForNull {
280280
return "*uuid.UUID"
281281
}
282+
if driver == opts.SQLDriverPGXV5 {
283+
return "pgtype.UUID"
284+
}
285+
282286
return "uuid.NullUUID"
283287

284288
case "inet":

0 commit comments

Comments
 (0)