Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-2839

Postgresql connection fails to escape column name if it is a reserved word, line "end".

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 4.2
    • None
    • Core Library, Modeler
    • None
    • JDK21

    Description

      As seen in the sample stack trace, I have a database table in postgresql named "end". Because this is a reserved word, it should be quoted, but the postgresql connector does not quote column names in queries nor in Modeler, when I request SQL generation. The SQL generated by the Modeler can easily be fixed, but the queries fail.

      I have tried it with the latest postgresql library available in maven.

      2024-01-30 17:19:43 [apache-cayenne] org.apache.cayenne.log.Slf4jJdbcEventLogger logQueryError
         INFO: *** error.
         org.postgresql.util.PSQLException: ERROR: syntax error at or near "end"
           Position: 26
             at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2676)
             at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2366)
             at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:356)
             at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:496)
             at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:413)
             at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190)
             at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:152)
             at org.apache.cayenne.access.jdbc.BatchAction.runAsIndividualQueries(BatchAction.java:196)
             at org.apache.cayenne.access.jdbc.BatchAction.performAction(BatchAction.java:93)
             at org.apache.cayenne.access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:97)
             at org.apache.cayenne.access.DataNode.performQueries(DataNode.java:273)
             at org.apache.cayenne.access.flush.DefaultDataDomainFlushAction.lambda$executeQueries$6(DefaultDataDomainFlushAction.java:178)
             at java.base/java.util.HashMap.forEach(HashMap.java:1429)
             at org.apache.cayenne.access.flush.DefaultDataDomainFlushAction.executeQueries(DefaultDataDomainFlushAction.java:177)
             at org.apache.cayenne.access.flush.DefaultDataDomainFlushAction.flush(DefaultDataDomainFlushAction.java:90)
             at org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:637)
             at org.apache.cayenne.access.DataDomain.onSyncNoFilters(DataDomain.java:609)
             at org.apache.cayenne.access.DataDomain$DataDomainSyncFilterChain.onSync(DataDomain.java:835)
             at org.apache.cayenne.tx.TransactionFilter.lambda$onSync$0(TransactionFilter.java:61)
             at org.apache.cayenne.tx.DefaultTransactionManager$BaseTransactionHandler.performInTransaction(DefaultTransactionManager.java:180)
             at org.apache.cayenne.tx.DefaultTransactionManager$NestedTransactionHandler.handle(DefaultTransactionManager.java:93)
             at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction(DefaultTransactionManager.java:62)
             at org.apache.cayenne.tx.DefaultTransactionManager.performInTransaction(DefaultTransactionManager.java:40)

      Attachments

        Activity

          People

            Unassigned Unassigned
            inphoenity Roland Szabó
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: