Skip to content

Problem with database/sql Nullable struct #706

Closed
@linxGnu

Description

@linxGnu

Issue description

Problem with insert/update null field using sql.NullInt64 and others database/sql Nullable struct

Example code

package main

import (
	_ "github.com/go-sql-driver/mysql"

	"database/sql"
	"fmt"
)

func main() {
	dsn := "root:123@tcp(localhost:3306)/tmp?charset=utf8&collation=utf8_general_ci&parseTime=true&loc=Asia%2FHo_Chi_Minh"
	db, _ := sql.Open("mysql", dsn)

	fmt.Println(db.Exec("INSERT INTO test (id, phone, address) VALUES (?, ?, ?)", 10, sql.NullInt64{Valid: true, Int64: 123}, sql.NullString{Valid: true, String: "abc"}))
}

Error log

<nil> sql: converting argument $2 type: unsupported type sql.NullInt64, a struct

Configuration

Driver version (or git SHA): v1.3-46-g78d399c

Go version: go1.9.2 darwin/amd64

Server version: MariaDB 10.2

Server OS: MacOS X 10.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions