skip to Main Content

Postgresql – Gorm NOT NULL constraints STILL PASSES FOR NULL values in the database Golang

In my struct, i have the following type Task struct { gorm.Model Id int `json:"id" gorm:"primaryKey;AUTO_INCREMENT"` UserId int `json:"user_id" gorm:"Index;not null" validate:"required"` TaskId int `json:"task_id" gorm:"Index;not null" validate:"required"` JobId int `json:"job_id" gorm:"not null" validate:"required"` Latitude float64 `json:"latitude" gorm:"not null" validate:"required"`…

VIEW QUESTION

Postgresql – GORM Error on insert or update on table violates foreign key constraint

I have the following set of GORM models, with 2 orders of one-to-many relations: type Order struct { ID string `gorm:"column:id"` ClientID string `gorm:"primaryKey;column:client_id"` Name string `gorm:"column:name"` Albums []Album `gorm:"foreignKey:RequestClientID"` } type Album struct { AlbumID string `gorm:"primaryKey;column:album_id"` RequestClientID string…

VIEW QUESTION
Back To Top
Search