Pg: Cannot create table with sql.NullInt64 fields

Created on 18 Jan 2017  Â·  1Comment  Â·  Source: go-pg/pg

Pretty straight-forward:

type UserModel struct {
    ID    int64 `sql:",unique,notnull"`

    Email string
    Name string

    Age sql.NullInt64
}

err := db.CreateTable(&UserModel{}, &orm.CreateTableOptions{})
if err != nil {
    log.Errorf("Could not create table: %v", err)
}

Log output:

15:47:42.938 main â–¶ ERRO 002 Could not create table: ERROR #42704 type "struct" does not exist (addr="[::1]:5432")

It then succeeds if I remove the field Age.

As you can imagine, being able to create tables from models with nullable fields is pretty important.

Most helpful comment

Should be fixed in v5.2.7

>All comments

Should be fixed in v5.2.7

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Alireza-Ta picture Alireza-Ta  Â·  3Comments

kieusonlam picture kieusonlam  Â·  6Comments

Labutin picture Labutin  Â·  3Comments

owentran picture owentran  Â·  6Comments

rhymes picture rhymes  Â·  5Comments