fix: pk forces the Type of the numeric to be TypeInt so that the user defined id type is invalid (#926)

This commit is contained in:
Target Liu
2020-11-08 00:51:50 +08:00
committed by GitHub
parent 122ee020b7
commit d993b59d90
2 changed files with 3 additions and 3 deletions

View File

@@ -919,7 +919,7 @@ func (f Field) size() int64 {
func (f Field) PK() *schema.Column {
c := &schema.Column{
Name: f.StorageKey(),
Type: field.TypeInt,
Type: f.Type.Type,
Key: schema.PrimaryKey,
Increment: true,
}

View File

@@ -14,9 +14,9 @@ import (
var (
// UsersColumns holds the columns for the "users" table.
UsersColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "id", Type: field.TypeUint64, Increment: true},
{Name: "name", Type: field.TypeString},
{Name: "user_spouse", Type: field.TypeInt, Unique: true, Nullable: true},
{Name: "user_spouse", Type: field.TypeUint64, Unique: true, Nullable: true},
}
// UsersTable holds the schema information for the "users" table.
UsersTable = &schema.Table{