Skip to content

Unable parse OR #1706

Closed
Closed

Description

@jpink

Hi,

when I initialize org.drewcarlson:kjob-jdbi the kjob or Jdbi generates query like INSERT OR REPLACE INTO kjobLocks VALUES (?, ?, ?) which I can't parse because I get: ParseException: Encountered unexpected token: "OR".

Activity

  1. manticore-projects commented on Dec 31, 2022

    @manticore-projects
    Contributor

    Greetings.

    INSERT OR REPLACE ... is not supported and far away from any standard or RDBMS I know. MERGE ... INTO ... would be more appropriate.

    The supported syntax are shown here.

  2. manticore-projects commented on Dec 31, 2022

    @manticore-projects
    Contributor

    Am I correct to assume, that you talk to MongoDB?
    If so, then support is slim because we very much focus on Relational DBs and Standard SQL. When MongoDB is defined as a NoSQL Database then a SQL Parser may be the wrong tool.

  3. jpink commented on Jan 10, 2023

    @jpink
    Author

    The problem is that I'm not writing the SQL the framework (Jdbi? probably) generates it. And the framework targets to SQLite, MySQL, PostegreSQL.

    I now use SQL filter or sanitizer in JDBC wrapper driver where I replace INSERT OR REPLACE to INSERT and that workaround works.

  4. jpink commented on Jan 10, 2023

    @jpink
    Author

    Can you support non-standard known syntax also. Or better can you replace it with MERGE ... INTO ... syntax?

  5. manticore-projects commented on Jan 11, 2023

    @manticore-projects
    Contributor

    Can you support non-standard known syntax also.

    We actually do support a lot of non-standard syntax and supporting your statement is possible. However, first of all you would need to point us on the exact syntax definition.

    I did not find any INSERT OR REPLACE INTO ... statement (only a MySQL REPLACE INTO... statement)

  6. manticore-projects commented on Jan 11, 2023

    @manticore-projects
    Contributor

    It seems to be very SQLite specific.

    We have the UPSERT statement, which seem to do the same thing.
    And there is REPLACE, which is similar too.

  7. manticore-projects commented on Jan 11, 2023

    @manticore-projects
    Contributor

    I got a POC working and will provide a patch today:

    expected: <insert or replace into kjoblocks values(?,?,?)> but was: <upsert into kjoblocks values(?,?,?)>
    Expected :insert or replace into kjoblocks values(?,?,?)
    Actual   :upsert into kjoblocks values(?,?,?)
    
  8. added a commit that references this issue on Jan 11, 2023
    dcd39e6
  9. added a commit that references this issue on Jan 20, 2023
    a00d77a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions