+
Skip to content

Update documentation for insertOrUpdate and bulkInsertOrUpdate #501

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

Merged
merged 1 commit into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@ public data class InsertOrUpdateExpression(
* on conflict (id) do update set salary = t_employee.salary + ?
* ```
*
* By default, the column used into the `on conflict` statement is the primary key you already defined in the schema definition. If you want, you can specify one or more columns for the `on conflict` statement like in the following example:
*
* ```kotlin
* database.insertOrUpdate(Employees) {
* set(it.id, 1)
* set(it.name, "vince")
* set(it.job, "engineer")
* set(it.salary, 1000)
* set(it.hireDate, LocalDate.now())
* set(it.departmentId, 1)
* onConflict(it.name, it.job) {
* set(it.salary, it.salary + 900)
* }
* }
* ```
* Generated SQL:
*
* ```sql
* insert into t_employee (id, name, job, salary, hire_date, department_id)
* values (?, ?, ?, ?, ?, ?)
* on conflict (name, job) do update set salary = t_employee.salary + ?
* ```
*
* @since 2.7
* @param table the table to be inserted.
* @param block the DSL block used to construct the expression.
Expand Down Expand Up @@ -115,6 +138,28 @@ public fun <T : BaseTable<*>> Database.insertOrUpdate(
* on conflict (id) do update set salary = t_employee.salary + ?
* returning id
* ```
* By default, the column used into the `on conflict` statement is the primary key you already defined in the schema definition. If you want, you can specify one or more columns for the `on conflict` statement like in the following example:
*
* ```kotlin
* database.insertOrUpdate(Employees) {
* set(it.id, 1)
* set(it.name, "vince")
* set(it.job, "engineer")
* set(it.salary, 1000)
* set(it.hireDate, LocalDate.now())
* set(it.departmentId, 1)
* onConflict(it.name, it.job) {
* set(it.salary, it.salary + 900)
* }
* }
* ```
* Generated SQL:
*
* ```sql
* insert into t_employee (id, name, job, salary, hire_date, department_id)
* values (?, ?, ?, ?, ?, ?)
* on conflict (name, job) do update set salary = t_employee.salary + ?
* ```
*
* @since 3.4.0
* @param table the table to be inserted.
Expand Down Expand Up @@ -162,6 +207,29 @@ public fun <T : BaseTable<*>, C : Any> Database.insertOrUpdateReturning(
* returning id, job
* ```
*
* By default, the column used into the `on conflict` statement is the primary key you already defined in the schema definition. If you want, you can specify one or more columns for the `on conflict` statement like in the following example:
*
* ```kotlin
* database.insertOrUpdate(Employees) {
* set(it.id, 1)
* set(it.name, "vince")
* set(it.job, "engineer")
* set(it.salary, 1000)
* set(it.hireDate, LocalDate.now())
* set(it.departmentId, 1)
* onConflict(it.name, it.job) {
* set(it.salary, it.salary + 900)
* }
* }
* ```
* Generated SQL:
*
* ```sql
* insert into t_employee (id, name, job, salary, hire_date, department_id)
* values (?, ?, ?, ?, ?, ?)
* on conflict (name, job) do update set salary = t_employee.salary + ?
* ```
*
* @since 3.4.0
* @param table the table to be inserted.
* @param returning the columns to return
Expand Down Expand Up @@ -210,6 +278,29 @@ public fun <T : BaseTable<*>, C1 : Any, C2 : Any> Database.insertOrUpdateReturni
* returning id, job, salary
* ```
*
* By default, the column used into the `on conflict` statement is the primary key you already defined in the schema definition. If you want, you can specify one or more columns for the `on conflict` statement like in the following example:
*
* ```kotlin
* database.insertOrUpdate(Employees) {
* set(it.id, 1)
* set(it.name, "vince")
* set(it.job, "engineer")
* set(it.salary, 1000)
* set(it.hireDate, LocalDate.now())
* set(it.departmentId, 1)
* onConflict(it.name, it.job) {
* set(it.salary, it.salary + 900)
* }
* }
* ```
* Generated SQL:
*
* ```sql
* insert into t_employee (id, name, job, salary, hire_date, department_id)
* values (?, ?, ?, ?, ?, ?)
* on conflict (name, job) do update set salary = t_employee.salary + ?
* ```
*
* @since 3.4.0
* @param table the table to be inserted.
* @param returning the columns to return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,29 @@ private fun <T : BaseTable<*>> Database.buildBulkInsertExpression(
* on conflict (id) do update set salary = t_employee.salary + ?
* ```
*
* By default, the column used into the `on conflict` statement is the primary key you already defined in the schema definition. If you want, you can specify one or more columns for the `on conflict` statement like in the following example:
*
* ```kotlin
* database.insertOrUpdate(Employees) {
* set(it.id, 1)
* set(it.name, "vince")
* set(it.job, "engineer")
* set(it.salary, 1000)
* set(it.hireDate, LocalDate.now())
* set(it.departmentId, 1)
* onConflict(it.name, it.job) {
* set(it.salary, it.salary + 900)
* }
* }
* ```
* Generated SQL:
*
* ```sql
* insert into t_employee (id, name, job, salary, hire_date, department_id)
* values (?, ?, ?, ?, ?, ?)
* on conflict (name, job) do update set salary = t_employee.salary + ?
* ```
*
* @param table the table to be inserted.
* @param block the DSL block used to construct the expression.
* @return the effected row count.
Expand Down Expand Up @@ -361,6 +384,29 @@ public fun <T : BaseTable<*>> Database.bulkInsertOrUpdate(
* returning id
* ```
*
* By default, the column used into the `on conflict` statement is the primary key you already defined in the schema definition. If you want, you can specify one or more columns for the `on conflict` statement like in the following example:
*
* ```kotlin
* database.insertOrUpdate(Employees) {
* set(it.id, 1)
* set(it.name, "vince")
* set(it.job, "engineer")
* set(it.salary, 1000)
* set(it.hireDate, LocalDate.now())
* set(it.departmentId, 1)
* onConflict(it.name, it.job) {
* set(it.salary, it.salary + 900)
* }
* }
* ```
* Generated SQL:
*
* ```sql
* insert into t_employee (id, name, job, salary, hire_date, department_id)
* values (?, ?, ?, ?, ?, ?)
* on conflict (name, job) do update set salary = t_employee.salary + ?
* ```
*
* @since 3.6.0
* @param table the table to be inserted.
* @param returning the column to return
Expand Down Expand Up @@ -414,6 +460,29 @@ public fun <T : BaseTable<*>, C : Any> Database.bulkInsertOrUpdateReturning(
* returning id, job
* ```
*
* By default, the column used into the `on conflict` statement is the primary key you already defined in the schema definition. If you want, you can specify one or more columns for the `on conflict` statement like in the following example:
*
* ```kotlin
* database.insertOrUpdate(Employees) {
* set(it.id, 1)
* set(it.name, "vince")
* set(it.job, "engineer")
* set(it.salary, 1000)
* set(it.hireDate, LocalDate.now())
* set(it.departmentId, 1)
* onConflict(it.name, it.job) {
* set(it.salary, it.salary + 900)
* }
* }
* ```
* Generated SQL:
*
* ```sql
* insert into t_employee (id, name, job, salary, hire_date, department_id)
* values (?, ?, ?, ?, ?, ?)
* on conflict (name, job) do update set salary = t_employee.salary + ?
* ```
*
* @since 3.6.0
* @param table the table to be inserted.
* @param returning the columns to return
Expand Down Expand Up @@ -468,6 +537,29 @@ public fun <T : BaseTable<*>, C1 : Any, C2 : Any> Database.bulkInsertOrUpdateRet
* returning id, job, salary
* ```
*
* By default, the column used into the `on conflict` statement is the primary key you already defined in the schema definition. If you want, you can specify one or more columns for the `on conflict` statement like in the following example:
*
* ```kotlin
* database.insertOrUpdate(Employees) {
* set(it.id, 1)
* set(it.name, "vince")
* set(it.job, "engineer")
* set(it.salary, 1000)
* set(it.hireDate, LocalDate.now())
* set(it.departmentId, 1)
* onConflict(it.name, it.job) {
* set(it.salary, it.salary + 900)
* }
* }
* ```
* Generated SQL:
*
* ```sql
* insert into t_employee (id, name, job, salary, hire_date, department_id)
* values (?, ?, ?, ?, ?, ?)
* on conflict (name, job) do update set salary = t_employee.salary + ?
* ```
*
* @since 3.6.0
* @param table the table to be inserted.
* @param returning the columns to return
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载