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

Batch update query ext #2228

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jarvvski
Copy link

@Jarvvski Jarvvski commented Sep 9, 2024

Description

Summary of the change: Adding a table extension for fluent usage of batchUpdate similar to batchInsert etc

Detailed description:

  • What: Detail what changes have been made in the PR.
  • Why: Explain the reasons behind the changes. Why were they necessary?
  • How: Describe how the changes were implemented, including any key aspects of the code modified or new features added.

Type of Change

Please mark the relevant options with an "X":

  • Bug fix
  • New feature
  • Documentation update

Updates/remove existing public API methods:

  • Is breaking change

Affected databases:

  • MariaDB
  • Mysql5
  • Mysql8
  • Oracle
  • Postgres
  • SqlServer
  • H2
  • SQLite

Checklist

  • Unit tests are in place
  • The build is green (including the Detekt check)
  • All public methods affected by my PR has up to date API docs
  • Documentation for my change is up to date

Related Issues

I'm pushing this up as a draft - not sure how the community feels about it. It's very much WIP that I was doing over the weekend, but pushing up now to gather initial feedback

fun <T : Table, E> T.batchUpdate(
data: Iterable<E>,
limit: Int? = null,
where: (SqlExpressionBuilder.() -> Op<Boolean>)? = null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right that every statement may have own where condition?

For example:

update t set v = "v1" where id = 1
update t set v = "v2" where id = 2
...

Will it be reflected with this API? I just wonder because where arg is one for the whole statement, and the parameters for it should be taken somehow from the data parameter.

@@ -499,6 +499,26 @@ fun <T : Table> T.updateReturning(
return ReturningStatement(this, returning, update)
}

fun <T : Table, E> T.batchUpdate(
data: Iterable<E>,
limit: Int? = null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't expect that standard update statment supports limit buy I may be wrong here.

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 this pull request may close these issues.

2 participants