You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@metamodel.apache.org by Dana Borger <Da...@sas.com> on 2017/07/19 15:12:54 UTC

Possible quoting bug in JdbcInsertBuilding + JdbcUpdateCallback.java

Looks like the 4.6.0 version of the method JdbcUpdateCallback.quoteIfNecessary() only quotes column names in these cases:

        if (identifier.indexOf(' ') != -1 || identifier.indexOf('-') != -1) {

So that if we have a table with a column named “ASmallInt” in Postgres, this results in an error because of its mixed case (Postgres treats unquoted identifiers as lower-case):

Error code=0, SQL state=42703
Exception details: request: /rest/documents, parameters:
Could not execute insert statement: INSERT INTO "x"."y" (id,first_name,last_name,ASmallInt)) VALUES (?,?,?,?): ERROR: column "asmallint" of relation "y" does not exist

. . .

        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2458)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2158)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:291)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:432)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:358)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:171)
        at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:138)
        at org.apache.metamodel.jdbc.JdbcSimpleUpdateCallback.executePreparedStatement(JdbcSimpleUpdateCallback.java:45)
        at org.apache.metamodel.jdbc.JdbcUpdateCallbcutePreparedStatement(JdbcUpdateCallback.java:57)
        at org.apache.metamodel.jdbc.JdbcInsertBuilder.execute(JdbcInsertBuilder.java:84)


Has anyone else run into this? Seems like the column names (and other identifiers) should be always quoted?

Best,
db


Re: Possible quoting bug in JdbcInsertBuilding + JdbcUpdateCallback.java

Posted by Kasper Sørensen <i....@gmail.com>.
I haven't seen this myself no TBH. But it might be dependent also on the
type/version of Postgres you have installed. Either way I think it sounds
like a legitimate bug to report on JIRA.

2017-07-19 8:12 GMT-07:00 Dana Borger <Da...@sas.com>:

>
>
> Looks like the 4.6.0 version of the method JdbcUpdateCallback.
> quoteIfNecessary() only quotes column names in these cases:
>
>
>
>         if (identifier.indexOf(' ') != -1 || identifier.indexOf('-') !=
> -1) {
>
>
>
> So that if we have a table with a column named “ASmallInt” in Postgres,
> this results in an error because of its mixed case (Postgres treats
> unquoted identifiers as lower-case):
>
>
>
> Error code=0, SQL state=42703
>
> Exception details: request: /rest/documents, parameters:
>
> Could not execute insert statement: INSERT INTO "x"."y"
> (id,first_name,last_name,ASmallInt)) VALUES (?,?,?,?): ERROR: column
> "asmallint" of relation "y" does not exist
>
>
>
> . . .
>
>
>
>         at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(
> QueryExecutorImpl.java:2458)
>
>         at org.postgresql.core.v3.QueryExecutorImpl.processResults(
> QueryExecutorImpl.java:2158)
>
>         at org.postgresql.core.v3.QueryExecutorImpl.execute(
> QueryExecutorImpl.java:291)
>
>         at org.postgresql.jdbc.PgStatement.executeInternal(
> PgStatement.java:432)
>
>         at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:358)
>
>         at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(
> PgPreparedStatement.java:171)
>
>         at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(
> PgPreparedStatement.java:138)
>
>         at org.apache.metamodel.jdbc.JdbcSimpleUpdateCallback.
> executePreparedStatement(JdbcSimpleUpdateCallback.java:45)
>
>         at org.apache.metamodel.jdbc.JdbcUpdateCallbcutePreparedSta
> tement(JdbcUpdateCallback.java:57)
>
>         at org.apache.metamodel.jdbc.JdbcInsertBuilder.execute(
> JdbcInsertBuilder.java:84)
>
>
>
>
>
> Has anyone else run into this? Seems like the column names (and other
> identifiers) should be always quoted?
>
>
>
> Best,
>
> db
>
>
>