Closed
Description
My structs
type BaseModel struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
DeletedAt *time.Time `json:"-"`
}
type Show struct {
BaseModel
Name string `json:"name""`
Videos []Video `gorm:"many2many:show_videos;"`
}
type Video struct {
BaseModel
StreamURL string `json:"streamURL"`
}
My code:
var shows []models.Show
dbMap.Preload("Videos").Order("name asc").Find(&shows)
SQL
SELECT * FROM "shows" WHERE ("shows".deleted_at IS NULL OR "shows".deleted_at <= '0001-01-02') ORDER BY name asc
SELECT * FROM "videos" INNER JOIN show_videos ON show_videos."video_id" = "videos"."id" WHERE (show_id in ())
When table shows
is empty, I get error:
ERROR: syntax error at or near ")"
LINE 1: ...show_videos."video_id" = "videos"."id" WHERE (show_id in ())
^
Metadata
Assignees
Labels
No labels