Skip to content

Insert ON CONFLICT parsed failed when composite primary multi columns #1633

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

Closed
leotu opened this issue Sep 16, 2022 · 3 comments · Fixed by #1745
Closed

Insert ON CONFLICT parsed failed when composite primary multi columns #1633

leotu opened this issue Sep 16, 2022 · 3 comments · Fixed by #1745
Assignees

Comments

@leotu
Copy link

leotu commented Sep 16, 2022

Ref: #1630

Failed when composite primary keys (id_1+id_2) --> "ON CONFLICT (id_1, id_2)"

INSERT into test_data (id_1, id_2, my_string_1, my_string_2)
VALUES ('id_1_A', 'id_2_A', 'my_string_1-new', 'my_string_2-new')
ON CONFLICT (id_1, id_2) DO UPDATE 
SET my_string_1 = 'my_string_1-update', my_string_2 = 'my_string_2-update';

Screenshot:
截圖 2022-09-16 11 46 10

DB tools validation successfully:

(1) Left is schema, right is sample data:
截圖 2022-09-16 11 44 40

(2) Executed successfully:
截圖 2022-09-16 11 45 23

(3) Update sample data:
截圖 2022-09-16 11 45 44

@wumpz
Copy link
Member

wumpz commented Sep 20, 2022

Thats right. This is not yet supported. JsqlParser only supports on conflict without an id list.

@manticore-projects
Copy link
Contributor

Duplicate #955

@manticore-projects
Copy link
Contributor

Please can someone have a look at the PostgreSQL Documentation and explain to me, where exactly it allows multiple columns?!

manticore-projects added a commit to manticore-projects/JSqlParser that referenced this issue Mar 18, 2023
@wumpz wumpz closed this as completed in 31ef1aa Mar 21, 2023
wumpz pushed a commit that referenced this issue Apr 27, 2023
* Fixes #1684: Support CREATE MATERIALIZED VIEW with AUTO REFRESH

Support parsing create view statements in Redshift with AUTO REFRESH
option.

* Reduce cyclomatic complexity in CreateView.toString

Extract adding the force option into a dedicated method resulting in the
cyclomatic complexity reduction of the CreateView.toString method.

* Enhanced Keywords

Add Keywords and document, which keywords are allowed for what purpose

* Fix incorrect tests

* Define Reserved Keywords explicitly
Derive All Keywords from Grammar directly
Generate production for Object Names (semi-) automatically
Add parametrized Keyword Tests

* Fix test resources

* Adjust Gradle to JUnit 5

Parallel Test execution
Gradle Caching
Explicitly request for latest JavaCC 7.0.10

* Do not mark SpeedTest for concurrent execution

* Remove unused imports

* Adjust Gradle to JUnit 5

Parallel Test execution
Gradle Caching
Explicitly request for latest JavaCC 7.0.10

* Do not mark SpeedTest for concurrent execution

* Remove unused imports

* Sphinx Documentation

Update the MANTICORE Sphinx Theme, but ignore it in GIT
Add the content to the Sphinx sites
Add a Gradle function to derive Stable and Snapshot version from GIT Tags
Add a Gradle GIT change task
Add a Gradle sphinx task
Add a special Test case for illustrating the use of JSQLParser

* doc: request for `Conventional Commit` messages

* feat: make important Classes Serializable

Implement Serializable for persisting via ObjectOutputStream

* chore: Make Serializable

* doc: Better integration of the RR diagrams

- apply neutral Sphinx theme
- insert the RR diagrams into the sphinx sources
- better documentation on Gradle dependencies
- link GitHub repository

* Merge

* feat: Oracle Alternative Quoting

- add support for Oracle Alternative Quoting e.g. `q'(...)'`
- fixes #1718
- add a Logo and FavIcon to the Website
- document recent changes on Quoting/Escaping
- add an example on building SQL from Java
- rework the README.md, promote the Website
- add Spotless Formatter, using Google Java Style (with Tab=4 Spaces)

* style: Appease PMD/Codacy

* doc: fix the issue template

- fix the issue template
- fix the -SNAPSHOT version number

* Update issue templates

* Update issue templates

* feat: Support more Statement Separators

- `GO`
- Slash `/`
- Two empty lines

* feat: FETCH uses EXPRESSION

- `FETCH` uses `EXPRESSION` instead of SimpleJDBCParameter only
- Visit/Accept `FETCH` `EXPRESSION` instead of `append` to String
- Visit/Accept `OFFSET` `EXPRESSION` instead of `append` to String
- Gradle: remove obsolete/incompatible `jvmArgs` from Test()

* style: apply Spotless

* test: commit missing test

* fix: JSon Operator can use Simple Function

Supports `Function() ->> Literal` (although `Function()` would not allow Nested Expression Parameters)

fixes #1571

* style: Reformat changed files and headers

* style: Remove unused variable

* feat: Add support for Hangul "\uAC00"-"\uD7A3"

fixes #1747

* style: expose `SetStatement` key-value list

fixes #1746

* style: Appease PMD/Codacy

* feat: `ConflictTarget` allows multiple `IndexColumnNames`

fixes #1749
fixes #1633
fixes #955

* doc: fix reference in the Java Doc

* build: better Upload Groovy Task

* feat: ParenthesedSelectBody and ParenthesedFromItem

- First properly working version
- Work in progress, 13 tests failing

* feat: ParenthesedSelectBody and ParenthesedFromItem

- delete unneeded ParenthesedJoin
- rename ParenthesisFromItem into ParenthesedFromItem

* feat: ParenthesedSelectBody and ParenthesedFromItem

- fix `NULLS FIRST` and `NULLS LAST`

* feat: ParenthesedSelectBody and ParenthesedFromItem

- fix Oracle Hints

* feat: ParenthesedSelectBody and ParenthesedFromItem

- parse `SetOperation` only after a (first plain) SelectBody has found, this fixes the performance issue
- one more special Oracle Test succeeds
- 5 remaining test failures

* feat: ParenthesedSelectBody and ParenthesedFromItem

- extract `OrderByElements` into `SelectBody`
- one more special Oracle Test succeeds
- all tests succeed

* style: Appease PMD/Codacy

* style: Appease PMD/Codacy

* feat: Refactor SelectBody implementations

- `SelectBody` implements `FromItem`
- get rid of `SubSelect` and `SpecialSubSelect`
- `Merge` can use `FromItem` instead of `SubSelect` or `Table`
- `LateralSubSelect` extends `ParenthesedSelectBody` directly
- Simplify the `Select` statement, although it is still redundant since     `SelectBody` also could implement `Statement` directly
- `WithItem` can use `SelectBody` directly, which allows for nested `WithItems`

BREAKING-CHANGE: Lots of redundant methods and intermediate removed

* feat: Refactor SelectBody implementations

- `SelectBody` implements `Statement` and so makes `Select` redundant
- get rid of `ValuesList`
- refactor `ValuesStatement` into `Values` which just implements `SelectBody` (and becomes a `Statement` and a `FromItem`), move to `select` package

BREAKING-CHANGE: Lots of redundant methods and intermediate removed

* style: Code cleanup

- remove 3 unused/obsolete productions
- appease PMD/Codacy

* feat: Merge `SelectBody` into `Select` Statement

- former `SelectBody` implements `Statement` and so becomes `Select`
- this reduces the AST by 1 hierarchy level

* style: Remove unused import

* test: @disabled invalid Test

* style: Appease PMD/Codacy

* test: Add a SubSelect Parsing Test

---------

Co-authored-by: zaza <tzarna@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants