Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: proper nullable types #898

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/server/templates/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export const apply = ({
let output = `
package database

import "database/sql"

${tables
.filter((table) => schemas.some((schema) => schema.name === table.schema))
.flatMap((table) =>
Expand Down Expand Up @@ -275,13 +273,13 @@ const GO_TYPE_MAP = {
type GoType = (typeof GO_TYPE_MAP)[keyof typeof GO_TYPE_MAP]

const GO_NULLABLE_TYPE_MAP: Record<GoType, string> = {
string: 'sql.NullString',
bool: 'sql.NullBool',
int16: 'sql.NullInt32',
int32: 'sql.NullInt32',
int64: 'sql.NullInt64',
float32: 'sql.NullFloat64',
float64: 'sql.NullFloat64',
string: '*string',
bool: '*bool',
int16: '*int16',
int32: '*int32',
int64: '*int64',
float32: '*float32',
float64: '*float64',
'[]byte': '[]byte',
'interface{}': 'interface{}',
'map[string]interface{}': 'map[string]interface{}',
Expand Down