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

fix: EXPOSED-541 #2233

Closed
wants to merge 1 commit into from
Closed

Conversation

langbiantianya
Copy link

Description

Summary of the change: In PostgreSQL's implementation of upsert, the update do not directly invoke the toString() method

Can be reproduced here

2024-09-11 10:37:09.379 [main] WARN  Exposed - Transaction attempt #2 failed: org.postgresql.util.PSQLException: ERROR: syntax error at or near "["
  位置:143. Statement(s): INSERT INTO test_upsert_table ("name", "number", age, tags) VALUES (?, ?, ?, ?) ON CONFLICT ("name", "number") DO UPDATE SET age=13, tags=[量子, 虚数]
org.jetbrains.exposed.exceptions.ExposedSQLException: org.postgresql.util.PSQLException: ERROR: syntax error at or near "["

Detailed description:

  • What: upsert when the set value is array , bulider sql err in postgresql,
  • Why: In PostgreSQL, the update value for upsert invokes the toString() method during the construction of SQL statements.
  • How: Instead of directly calling the toString() method, employ a method consistent with the update method to construct the SQL query

Type of Change

Please mark the relevant options with an "X":

  • [ x ] Bug fix
  • New feature
  • Documentation update

Updates/remove existing public API methods:

  • Is breaking change

Affected databases:

  • MariaDB
  • Mysql5
  • Mysql8
  • Oracle
  • [ x ] 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

@bog-walk bog-walk self-assigned this Sep 11, 2024
@bog-walk
Copy link
Member

Hi @langbiantianya Thanks for starting this, but a previous PR #2224 that addresses the underlying issue has just been merged (EXPOSED-509). It used a similar fix to cover all dialects, so I just added a test to ensure it also covers your specific use case with arrays.

@bog-walk bog-walk closed this Sep 11, 2024
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