You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:145
[2.766ms] [rows:1] SELECT count(*) FROM information_schema.tables WHERE table_schema = CURRENT_SCHEMA() AND table_name = 'foos' AND table_type = 'BASE TABLE'
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:20
[0.381ms] [rows:1] SELECT CURRENT_DATABASE()
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:330
[9.333ms] [rows:-] SELECT c.column_name, c.is_nullable = 'YES', c.udt_name, c.character_maximum_length, c.numeric_precision, c.numeric_precision_radix, c.numeric_scale, c.datetime_precision, 8 * typlen, c.column_default, pd.description FROM information_schema.columns AS c JOIN pg_type AS pgt ON c.udt_name = pgt.typname LEFT JOIN pg_catalog.pg_description as pd ON pd.objsubid = c.ordinal_position AND pd.objoid = (SELECT oid FROM pg_catalog.pg_class WHERE relname = c.table_name AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = c.table_schema)) where table_catalog = 'gorm_debug' AND table_schema = CURRENT_SCHEMA() AND table_name = 'foos'
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:461
[0.457ms] [rows:-] SELECT * FROM "foos" LIMIT 1
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:400
[9.246ms] [rows:-] SELECT c.column_name, constraint_type FROM information_schema.table_constraints tc JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name) JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema AND tc.table_name = c.table_name AND ccu.column_name = c.column_name WHERE constraint_type IN ('PRIMARY KEY', 'UNIQUE') AND c.table_catalog = 'gorm_debug' AND c.table_schema = CURRENT_SCHEMA() AND c.table_name = 'foos'
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:430
[0.852ms] [rows:-] SELECT a.attname as column_name, format_type(a.atttypid, a.atttypmod) AS data_type
FROM pg_attribute a JOIN pg_class b ON a.attrelid = b.relfilenode AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = CURRENT_SCHEMA())
WHERE a.attnum > 0 -- hide internal columns
AND NOT a.attisdropped -- hide deleted columns
AND b.relname = 'foos'
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:218
[5.948ms] [rows:0] SELECT description FROM pg_catalog.pg_description WHERE objsubid = (SELECT ordinal_position FROM information_schema.columns WHERE table_schema = CURRENT_SCHEMA() AND table_name = 'foos' AND column_name = 'id') AND objoid = (SELECT oid FROM pg_catalog.pg_class WHERE relname = 'foos' AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = CURRENT_SCHEMA()))
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:20
[0.200ms] [rows:1] SELECT CURRENT_DATABASE()
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:330
[5.446ms] [rows:-] SELECT c.column_name, c.is_nullable = 'YES', c.udt_name, c.character_maximum_length, c.numeric_precision, c.numeric_precision_radix, c.numeric_scale, c.datetime_precision, 8 * typlen, c.column_default, pd.description FROM information_schema.columns AS c JOIN pg_type AS pgt ON c.udt_name = pgt.typname LEFT JOIN pg_catalog.pg_description as pd ON pd.objsubid = c.ordinal_position AND pd.objoid = (SELECT oid FROM pg_catalog.pg_class WHERE relname = c.table_name AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = c.table_schema)) where table_catalog = 'gorm_debug' AND table_schema = CURRENT_SCHEMA() AND table_name = 'foos'
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:461
[0.167ms] [rows:-] SELECT * FROM "foos" LIMIT 1
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:400
[7.104ms] [rows:-] SELECT c.column_name, constraint_type FROM information_schema.table_constraints tc JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name) JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema AND tc.table_name = c.table_name AND ccu.column_name = c.column_name WHERE constraint_type IN ('PRIMARY KEY', 'UNIQUE') AND c.table_catalog = 'gorm_debug' AND c.table_schema = CURRENT_SCHEMA() AND c.table_name = 'foos'
2022/04/03 18:00:11 /home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:430
[0.376ms] [rows:-] SELECT a.attname as column_name, format_type(a.atttypid, a.atttypmod) AS data_type
FROM pg_attribute a JOIN pg_class b ON a.attrelid = b.relfilenode AND relnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = CURRENT_SCHEMA())
WHERE a.attnum > 0 -- hide internal columns
AND NOT a.attisdropped -- hide deleted columns
AND b.relname = 'foos'
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x81bdb7]
goroutine 1 [running]:
database/sql.(*ColumnType).DatabaseTypeName(...)
/opt/go/src/database/sql/sql.go:3172
gorm.io/gorm/migrator.ColumnType.DatabaseTypeName(...)
/home/ferdinand/go/pkg/mod/gorm.io/gorm@v1.23.4/migrator/column_type.go:44
gorm.io/driver/postgres.Migrator.AlterColumn.func1.1(0xc0002aa680?)
/home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:251 +0xf7
gorm.io/gorm.(*DB).Connection(0x865960?, 0xc0001cf360)
/home/ferdinand/go/pkg/mod/gorm.io/gorm@v1.23.4/finisher_api.go:539 +0x102
gorm.io/driver/postgres.Migrator.AlterColumn.func1(0xc0003a4700)
/home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:249 +0x26b
gorm.io/gorm/migrator.Migrator.RunWithValue({{0xc0?, 0xc00038cdb0?, {0x97e320?, 0xc00028ae40?}}}, {0x843460?, 0xc000298ae0}, 0xc0001cf7a0)
/home/ferdinand/go/pkg/mod/gorm.io/gorm@v1.23.4/migrator/migrator.go:52 +0x13c
gorm.io/driver/postgres.Migrator.AlterColumn({{{0x0?, 0xc00038cdb0?, {0x97e320?, 0xc00028ae40?}}}}, {0x843460?, 0xc000298ae0?}, {0x83a1be?, 0x0?})
/home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:237 +0xb1
gorm.io/gorm/migrator.Migrator.MigrateColumn({{0xcb?, 0xc00038cbd0?, {0x97e320?, 0xc00028ae40?}}}, {0x843460, 0xc000298ae0}, 0xc0002965a0, {0x97e458, 0xc0002abd40})
/home/ferdinand/go/pkg/mod/gorm.io/gorm@v1.23.4/migrator/migrator.go:464 +0x689
gorm.io/driver/postgres.Migrator.MigrateColumn({{{0x0?, 0xc00038cbd0?, {0x97e320?, 0xc00028ae40?}}}}, {0x843460, 0xc000298ae0}, 0xc0002965a0, {0x97e458?, 0xc0002abd40?})
/home/ferdinand/go/pkg/mod/gorm.io/driver/postgres@v1.3.3/migrator.go:205 +0x95
gorm.io/gorm/migrator.Migrator.AutoMigrate.func1(0xc0002bcc40)
/home/ferdinand/go/pkg/mod/gorm.io/gorm@v1.23.4/migrator/migrator.go:120 +0x17b
gorm.io/gorm/migrator.Migrator.RunWithValue({{0x30?, 0xc00029b830?, {0x97e320?, 0xc00028ae40?}}}, {0x843460?, 0xc000298ae0}, 0xc0001cfe10)
/home/ferdinand/go/pkg/mod/gorm.io/gorm@v1.23.4/migrator/migrator.go:52 +0x13c
gorm.io/gorm/migrator.Migrator.AutoMigrate({{0x0?, 0xc00029b830?, {0x97e320?, 0xc00028ae40?}}}, {0xc0002b6a20?, 0x0?, 0x0?})
/home/ferdinand/go/pkg/mod/gorm.io/gorm@v1.23.4/migrator/migrator.go:101 +0x1ce
gorm.io/gorm.(*DB).AutoMigrate(0x97e168?, {0xc0002b6a20, 0x1, 0x1})
/home/ferdinand/go/pkg/mod/gorm.io/gorm@v1.23.4/migrator.go:28 +0x43
main.main()
/home/ferdinand/dev/gorm-bug/main.go:24 +0x1ba
Process finished with the exit code 2
The text was updated successfully, but these errors were encountered:
Sorry for skipping the playground PR, but I think the below snippet should explain the issue well enough.
Example
Here's the output:
The text was updated successfully, but these errors were encountered: