Skip to content

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.


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.

@ShreckYe
Copy link
Contributor

+1 for this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants