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

Allow to manually specify field names that need to be updated #338

Open
lafriks opened this issue Aug 18, 2023 · 4 comments
Open

Allow to manually specify field names that need to be updated #338

lafriks opened this issue Aug 18, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@lafriks
Copy link
Contributor

lafriks commented Aug 18, 2023

In some cases you need to specifically save to database only some fields from struct and do not update any others. So it would be nice to specify something like:

db.Update(ctx, &t, rel.Fields("first_name", "last_name", "date_modifed"))

Also would be nice to specify fields in struct comments that this field should never be included in update (pk already is excluded but there are some fields that also can not be updated (like for partitioned tables etc). created_at should probably be excluded by default for example

Currently in postgres I'm having error ERROR: modifying the partition value of rows is not allowed (SQLSTATE 0A000) because of that and only option is to make update manually for this case

@lafriks lafriks added the enhancement New feature or request label Aug 18, 2023
@Fs02
Copy link
Member

Fs02 commented Aug 18, 2023

probably we also need to provide exclude function?

@lafriks
Copy link
Contributor Author

lafriks commented Aug 18, 2023

Probably both would be nice to have

@lafriks
Copy link
Contributor Author

lafriks commented Aug 18, 2023

I tried to look into this but I lack a bit of knowledge how changesets are built and where to add these options

@Fs02
Copy link
Member

Fs02 commented Aug 19, 2023

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

No branches or pull requests

2 participants