-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Labels
type:questiongeneral questionsgeneral questions
Description
Your Question
I have following models:
type Country struct {
NumCode uint `gorm:"primaryKey"`
Name string
Code2 string `gorm:"size:2"`
Code3 string `gorm:"size:3"`
}
import "overtime/pkg/model/types"
type ChangePeriod struct {
ID uint `gorm:"primaryKey;autoIncrement"`
CountryNumCode uint
Country Country `gorm:"index:idx_country_date_ranges,priority:1"`
Period types.DateRange `gorm:"type:daterange; index:idx_country_date_ranges, type:gist, priority:2"`
Comment string
}During initial automigration despite table change_periods is created correctly with the foreign key country_num_code, I get the following error during index creation:
ERROR: unterminated quoted identifier at or near "")" (SQLSTATE 42601)
[rows:0] CREATE INDEX IF NOT EXISTS "idx_country_date_ranges" ON "change_periods" USING gist(","period")
Worth to mention, if I modify ChangePeriod as follows
type ChangePeriod struct {
ID uint `gorm:"primaryKey;autoIncrement"`
CountryNumCode uint `gorm:"index:idx_country_date_ranges,priority:1"`
Country Country
Period types.DateRange `gorm:"type:daterange; index:idx_country_date_ranges, type:gist, priority:2"`
Comment string
}
Index is created successfully with the following SQL statement:
CREATE INDEX IF NOT EXISTS "idx_country_date_ranges" ON "change_periods" USING gist("country_num_code","period")
Do I get the whole idea of gorm tags wrong or is it a shortcoming/bug?
The document you expected this should be explained
Expected answer
Metadata
Metadata
Assignees
Labels
type:questiongeneral questionsgeneral questions