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

Associating to a model with a not null field shouldn't require those fields during association #7295

Open
rickyManalo opened this issue Nov 28, 2024 · 1 comment
Assignees
Labels
type:feature_request feature request

Comments

@rickyManalo
Copy link

Describe the feature

I think the title already describes what I want.

Motivation

I was working on some overhaul of my models when I got a weird issue when I did a multiple associations for a pretty big model. The 2 previous associations worked fine but the last one didn't, which is a model with a few not null fields, complained that I didn't supply the not null field values. And I don't think I should. Anyway, here's the error I got:

farm_handler.go:156 NOT NULL constraint failed: hauler_user_details.business_address_municipality_id
[0.000ms] [rows:0] INSERT INTO hauler_user_details (id,created_at,updated_at,deleted_at,for_user_id) VALUES ("e9d6e156-0aae-4798-9572-85ecb4f78c8e","2024-11-28 12:01:20.293","2024-11-28 12:01:20.293",NULL,"") ON CONFLICT DO NOTHING RETURNING id,business_name,business_address_street,business_address_subdivision,business_address_sitio,business_address_barangay,business_address_municipality_id,business_address_province_id,business_address_region_id

farm_handler.go:156 NOT NULL constraint failed: hauler_user_details.business_address_municipality_id; NOT NULL constraint failed: hauler_user_details.business_address_municipality_id
[2.120ms] [rows:1] UPDATE farms SET updated_at="2024-11-28 12:01:20.292" WHERE farms.deleted_at IS NULL AND id = "4dc0ef0f-9335-4d1a-a540-dff51e55f09c"

When I did supply the not null fields, the association worked

@github-actions github-actions bot added the type:feature_request feature request label Nov 28, 2024
@rickyManalo rickyManalo changed the title Associating to a model with a not null field shouldn't be required during association Associating to a model with a not null field shouldn't be require those fields during association Nov 28, 2024
@rickyManalo rickyManalo changed the title Associating to a model with a not null field shouldn't be require those fields during association Associating to a model with a not null field shouldn't require those fields during association Nov 28, 2024
@rickyManalo
Copy link
Author

I did some test and it seems like supplying those not null fields with a "default" value is a workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature_request feature request
Projects
None yet
Development

No branches or pull requests

2 participants