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

Syntax Error when saving active model that sets nothing #1376

Closed
billy1624 opened this issue Jan 9, 2023 Discussed in #1371 · 4 comments · Fixed by #1384
Closed

Syntax Error when saving active model that sets nothing #1376

billy1624 opened this issue Jan 9, 2023 Discussed in #1371 · 4 comments · Fixed by #1384
Assignees
Milestone

Comments

@billy1624
Copy link
Member

Discussed in #1371

Originally posted by lihe07 January 8, 2023
I have a ActiveModel like this;

ActiveModel {
    id; Unchanged(1),
    name: NotSet,
    password: NotSet
}

The SQL query for saving this looks like that:

UPDATE
  `users`
SET
WHERE
  `users`.`id` = ?

And that leads to a syntax error (empty set section).

I'm considering whether it's sea-orm's task to determine if the ActiveModel does noting or not.

@billy1624
Copy link
Member Author

Hey @lihe07, thanks for bring this up to the spotlight. I think this is something that we need to "fix".

IMO when updating / saving a existing ActiveModel with all its value being Unchanged or NotSet, the expected behaviour should be no-op. That's to skip firing any SQL statement.

To achieve that we need to check the values field of sea_query::UpdateStatement is empty at executor/update.rs.

@lihe07
Copy link

lihe07 commented Jan 9, 2023

@billy1624 Thanks! I'd be happy to work this out if I can!
(and I don't need a patch for my project either)

@billy1624
Copy link
Member Author

Hey @lihe07, thanks for the interest!! Sorry, I didn't realise you want to take this. Please check my PR at #1384

@lihe07
Copy link

lihe07 commented Jan 12, 2023

Never mind! I'll keep an eye out too, if there's anything I can do to help.

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

Successfully merging a pull request may close this issue.

2 participants