Skip to content

use with github.com/volatiletech/null/v9 panics #127

@msonawane

Description

@msonawane

Describe the bug
A clear and concise description of what the bug is.

if model has null.String fields INSERT panics with
panic: jet: null.String type can not be used as SQL query parameter

at internal/jet/sql_builder.go:238 due to


default:
		if strBindValue, ok := bindVal.(toStringInterface); ok {
			return stringQuote(strBindValue.String())
		}
		panic(fmt.Sprintf("jet: %s type can not be used as SQL query parameter", reflect.TypeOf(value).String()))
	}

Environment (please complete the following information):

  • OS :Linux
  • Database: postgres
  • Database driver: pgx
  • Jet version: 2.7.1

Code snippet

import (
	"time"

	"github.com/volatiletech/null/v9"
)

type OrgUser struct {
	ID           int64 `sql:"primary_key"`
	Name         string
	IsEmployee   *bool
	Salutation   null.String
	FirstName    null.String
	LastName     null.String
	Telephone    null.String
	Mobile       null.String
}
stmt := table.OrgUser.INSERT(table.OrgUser.AllColumns).
		MODEL(user)
result, err := stmt.ExecContext(ctx, db)

Expected behavior
null.String implements scanner and valuer interfaces. insert should work

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions