This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch past-M2
in repository https://gitbox.apache.org/repos/asf/cayenne.git
The following commit(s) were added to refs/heads/past-M2 by this push:
new e19362368 CAY-2961 PostgreSQL "text" column is reverse-engineered as
CLOB
e19362368 is described below
commit e193623680978b0f6ca6945008dd6eda7026723a
Author: Andrus Adamchik <[email protected]>
AuthorDate: Fri Jun 12 18:46:13 2026 -0400
CAY-2961 PostgreSQL "text" column is reverse-engineered as CLOB
---
RELEASE-NOTES.txt | 1 +
.../cayenne/dba/postgres/PostgresAdapter.java | 30 ++++++++--------------
2 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index c08229e56..38baf8ef2 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -21,6 +21,7 @@ Bug Fixes:
CAY-2958 Empty join is saved
CAY-2959 Modeler: DbRelationship dialog "Cancel" doesn't cancel
CAY-2960 Undoing renamed relationship change throws
+CAY-2961 PostgreSQL "text" column is reverse-engineered as CLOB
----------------------------------
Release: 5.0-M2
diff --git
a/cayenne/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
b/cayenne/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
index 7420887f8..897de4c20 100644
--- a/cayenne/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
+++ b/cayenne/src/main/java/org/apache/cayenne/dba/postgres/PostgresAdapter.java
@@ -22,7 +22,6 @@ package org.apache.cayenne.dba.postgres;
import org.apache.cayenne.CayenneRuntimeException;
import org.apache.cayenne.access.DataNode;
import org.apache.cayenne.access.sqlbuilder.sqltree.SQLTreeProcessor;
-import org.apache.cayenne.access.translator.ParameterBinding;
import org.apache.cayenne.access.translator.procedure.ProcedureTranslator;
import org.apache.cayenne.access.types.CharType;
import org.apache.cayenne.access.types.ExtendedType;
@@ -44,7 +43,6 @@ import org.apache.cayenne.query.Query;
import org.apache.cayenne.query.SQLAction;
import org.apache.cayenne.resource.ResourceLocator;
-import java.sql.PreparedStatement;
import java.sql.Types;
import java.util.Collection;
import java.util.Collections;
@@ -124,25 +122,17 @@ public class PostgresAdapter extends JdbcAdapter {
@Override
public DbAttribute buildAttribute(String name, String typeName, int type,
int size, int scale, boolean allowNulls) {
- if ("json".equalsIgnoreCase(typeName)) {
- type = Types.OTHER;
- }
- // "bytea" maps to pretty much any binary type, so
- // it is up to us to select the most sensible default.
- // And the winner is LONGVARBINARY
- else if (BYTEA.equalsIgnoreCase(typeName)) {
- type = Types.LONGVARBINARY;
- }
- // oid is returned as INTEGER, need to make it BLOB
- else if ("oid".equals(typeName)) {
- type = Types.BLOB;
- }
- // somehow the driver reverse-engineers "text" as VARCHAR, must be CLOB
- else if ("text".equalsIgnoreCase(typeName)) {
- type = Types.CLOB;
- }
+ int amendedType = switch (typeName != null ? typeName.toLowerCase() :
"") {
+ case "json" -> Types.OTHER;
+ // "bytea" maps to pretty much any binary type, so it is up to us
to select the most sensible default.
+ // And the winner is LONGVARBINARY
+ case BYTEA -> Types.LONGVARBINARY;
+ // oid is returned as INTEGER, need to make it BLOB
+ case "oid" -> Types.BLOB;
+ default -> type;
+ };
- return super.buildAttribute(name, typeName, type, size, scale,
allowNulls);
+ return super.buildAttribute(name, typeName, amendedType, size, scale,
allowNulls);
}
@Override