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

feat: EXPOSED-486 Support REPLACE INTO ... SELECT clause #2199

Merged
merged 2 commits into from
Aug 16, 2024

Conversation

bog-walk
Copy link
Member

Description

Summary of the change:
Adds an overload for replace() that accepts a query as an argument, in the same way that insert() can accept a query instead of column-value assignments.

Detailed description:

  • Why:
    It is already possible to generate SQL like INSERT INTO ... SELECT using insert() with a query parameter and REPLACE INTO ... VALUES is already supported by replace(). But it is not possible to generate REPLACE INTO ... SELECT without customizing the statement classes.
  • What:
    It is now possible to generate this statement out of the box.
  • How:
    • Adds a new class ReplaceSelectStatement that extends InsertSelectStatement.
    • Adds a new function Table.replace(query).

Type of Change

Please mark the relevant options with an "X":

  • New feature
  • Documentation update

Affected databases:

  • MariaDB
  • Mysql5
  • Mysql8
  • Oracle
  • Postgres
  • SqlServer
  • H2 (MySQL-related only)
  • 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

EXPOSED-486

@bog-walk bog-walk requested review from e5l and joc-a August 13, 2024 20:32
Existing insert() has an overload that accepts a query argument to generate SQL like
INSERT INTO ... SELECT. replace() also exists for supporting databases, but does
not have a similar overload.

This implements a new statement class that extends InsertSelectStatement and provides
a new extension function overload.
- Rebase from main
- Fix incorrect KDocs
- Remove detekt warning from test name & mutable properties
- Replace duplicate code
@bog-walk bog-walk force-pushed the bog-walk/add-replace-into-select branch from 30e6c09 to a5a45f6 Compare August 16, 2024 01:23
@bog-walk bog-walk merged commit f2670fc into main Aug 16, 2024
5 checks passed
@bog-walk bog-walk deleted the bog-walk/add-replace-into-select branch August 16, 2024 02:09
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