X Tutup
The Wayback Machine - https://web.archive.org/web/20201206194138/https://github.com/go-pg/pg/issues/1700
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random constraint name allocation #1700

Open
MohitKS5 opened this issue Aug 28, 2020 · 0 comments
Open

Random constraint name allocation #1700

MohitKS5 opened this issue Aug 28, 2020 · 0 comments

Comments

@MohitKS5
Copy link

@MohitKS5 MohitKS5 commented Aug 28, 2020

go-pg doesn't follow any fixed constraint name conventions.

type TestAccess struct {
	Id        string   `pg:"type:uuid,default:uuid_generate_v4()" json:"id"`
	BatchId   string   `pg:"type:uuid,on_delete:CASCADE,unique:batch_id_test_id" json:"batch_id,omitempty"`
	Batch     *Batch   `json:"batch,omitempty"`
	StudentId string   `pg:"type:uuid,on_delete:CASCADE" json:"student_id,omitempty"`
	Student   *Student `json:"student,omitempty"`
	TestId    string   `pg:",type:uuid,on_delete:CASCADE,notnull,unique:batch_id_test_id" json:"-"`
	Test      *Test    `json:"test,omitempty"`
}

On this model, sometimes the constraint is named test_accesses_batch_id_test_id_key and sometimes test_accesses_test_id_batch_id_key which makes it very difficult to use queries like ON CONFLICT ON CONSTRAINT ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup