Skip to content

Commit 83c37d3

Browse files
authoredMar 5, 2025
fix: proper nullable types for Go code gen (#898)
* fix: proper nullable types * fix: unused imports * fix: tests
1 parent d8734fb commit 83c37d3

File tree

2 files changed

+192
-196
lines changed

2 files changed

+192
-196
lines changed
 

‎src/server/templates/go.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ export const apply = ({
3434
let output = `
3535
package database
3636
37-
import "database/sql"
38-
3937
${tables
4038
.filter((table) => schemas.some((schema) => schema.name === table.schema))
4139
.flatMap((table) =>
@@ -275,13 +273,13 @@ const GO_TYPE_MAP = {
275273
type GoType = (typeof GO_TYPE_MAP)[keyof typeof GO_TYPE_MAP]
276274

277275
const GO_NULLABLE_TYPE_MAP: Record<GoType, string> = {
278-
string: 'sql.NullString',
279-
bool: 'sql.NullBool',
280-
int16: 'sql.NullInt32',
281-
int32: 'sql.NullInt32',
282-
int64: 'sql.NullInt64',
283-
float32: 'sql.NullFloat64',
284-
float64: 'sql.NullFloat64',
276+
string: '*string',
277+
bool: '*bool',
278+
int16: '*int16',
279+
int32: '*int32',
280+
int64: '*int64',
281+
float32: '*float32',
282+
float64: '*float64',
285283
'[]byte': '[]byte',
286284
'interface{}': 'interface{}',
287285
'map[string]interface{}': 'map[string]interface{}',

0 commit comments

Comments
 (0)
Failed to load comments.