Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Feature(Surrealdb Core) - Allow ON DUPLICATE KEYS to update by record AND add update to rpc#5653

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

Aymankht
Copy link
Contributor

@AymankhtAymankht commentedMar 11, 2025
edited
Loading

vThank you for submitting this pull request. We really appreciate you spending the time to work on SurrealDB. 🚀 🎉

What is the motivation?

I wanted to insert multiple records, but if the key exists to update the existing record with a specific update for each insertion. I thought Upsert would a be suitable canidate, but Upsert weirdly mimics Update and it does not allow multiple record upsertions at once. I didnt want to rewrite the Upsert from ground up, so I decided just to adjust INSERT statement. So, I can define for each record I am inserting a compatible update (or not).
The implementation was heavily motivated for usage in sdks, have less request/ not having to use raw sql code, to archive big data Operations.

What does this change do?

It extends the capability of ON DUPLICATE KEY UPDATE.
@field =@value will still work and corresponds to: for all inserts this change will be implemneted if it already exists.

[{@field =@value, ... },...] can now also be used: each index of the array correponds to the index of the inserts

  • if one index should have no updates just leave it emtpy [{@field =@value, ... }, {}, {@field =@value, ... }]
  • if only one is provided it will default to one update for all insert
  • the index matching requires the array to have the same number of 'updates' of records as the number of records to be inserted (except if length is one)

What is your testing strategy?

added tests

Is this related to any issues?

  • No related issues

Does this change need documentation?

surrealdb/docs.surrealdb.com#1227

Have you read the Contributing Guidelines?

Yes, I have read theContributing Guidelines

musjj reacted with thumbs up emoji
@AymankhtAymankht requested review fromtobiemh anda team ascode ownersMarch 11, 2025 15:33
@AymankhtAymankht changed the titleFeature - Allow ON DUPLICATE KEYS to update by recordFeature(Surrealdb Core) - Allow ON DUPLICATE KEYS to update by recordMar 11, 2025
@AymankhtAymankht requested a review froma team as acode ownerMarch 17, 2025 15:40
@AymankhtAymankht changed the titleFeature(Surrealdb Core) - Allow ON DUPLICATE KEYS to update by recordFeature(Surrealdb Core) - Allow ON DUPLICATE KEYS to update by record AND add update to rpcMar 24, 2025
@AymankhtAymankht marked this pull request as draftMarch 27, 2025 15:52
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tobiemhtobiemhAwaiting requested review from tobiemhtobiemh is a code owner

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@Aymankht

[8]ページ先頭

©2009-2025 Movatter.jp