You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2025/09/30 09:58:47 UTC

(empire-db) branch master updated: EMPIREDB-477 Column: added isCaseSensitive property

This is an automated email from the ASF dual-hosted git repository.

doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git


The following commit(s) were added to refs/heads/master by this push:
     new da175378 EMPIREDB-477 Column: added isCaseSensitive property
da175378 is described below

commit da175378d6e62ef6bfc22bc9a72e2fc6a80b3a58
Author: Rainer Döbele <do...@apache.org>
AuthorDate: Tue Sep 30 11:58:43 2025 +0200

    EMPIREDB-477
    Column: added isCaseSensitive property
---
 .../empire/jsf2/utils/TagEncodingHelper.java       |  6 +++++
 .../main/java/org/apache/empire/data/Column.java   |  9 ++++++++
 .../org/apache/empire/data/bean/BeanProperty.java  | 11 +++++++++
 .../main/java/org/apache/empire/db/DBColumn.java   | 27 ++++++++++++++++++++++
 4 files changed, 53 insertions(+)

diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
index d019932b..d6ab6a0d 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
@@ -226,6 +226,12 @@ public class TagEncodingHelper implements NamingContainer
             return true;
         }
 
+        @Override
+        public boolean isCaseSensitive()
+        {
+            return (expr instanceof Column) ? ((Column)expr).isCaseSensitive() : false;
+        }
+
         @Override
         public Object validateValue(Object value)
         {
diff --git a/empire-db/src/main/java/org/apache/empire/data/Column.java b/empire-db/src/main/java/org/apache/empire/data/Column.java
index aaaf5774..398e5e83 100644
--- a/empire-db/src/main/java/org/apache/empire/data/Column.java
+++ b/empire-db/src/main/java/org/apache/empire/data/Column.java
@@ -40,6 +40,8 @@ public interface Column extends ColumnExpr
     public static final String COLATTR_ENUMTYPE        = "enumType";
     public static final String COLATTR_NULLTEXT        = "nullText";
     public static final String COLATTR_NORMCOLUMN      = "normColumn";           // normalized column
+    public static final String COLATTR_REFCOLUMNS      = "refColumns";           // reference columns
+    public static final String COLATTR_CASESENSITIVE   = "caseSensitive";        // true/false
 
     public static final String COLATTR_MINLENGTH       = "minLength";
     public static final String COLATTR_MINVALUE        = "minValue";
@@ -91,6 +93,13 @@ public interface Column extends ColumnExpr
      */
     boolean isReadOnly();
 
+    /**
+     * Returns whether or not a column is case sensitive
+     * If not explicitly set, the case sensitivity is true for all text fields (VARCHAR, CLOB) except if an EnumType is set.
+     * @return true if the column is case sensitive or false if not
+     */
+    boolean isCaseSensitive();
+    
     /**
      * Returns all metadata attributes.
      * @return set of metadata attributes
diff --git a/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java b/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java
index 1b49f2ba..9006e1ea 100644
--- a/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java
+++ b/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java
@@ -244,6 +244,17 @@ public class BeanProperty implements Column
         return (dataType==DataType.AUTOINC);
     }
 
+    @Override
+    public boolean isCaseSensitive()
+    {
+        Object value = getAttribute(Column.COLATTR_CASESENSITIVE);
+        if (value==null)
+        {   // default is true for VARCHAR and CLOB except if EnumType is set
+            return getDataType().isText() && (getEnumType()==null);
+        }
+        return ObjectUtils.getBoolean(value);
+    }
+
     @Override
     public boolean isRequired()
     {
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBColumn.java b/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
index 890f52f2..b011a255 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.Set;
 
 import org.apache.empire.commons.Attributes;
+import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.Options;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.Column;
@@ -233,6 +234,32 @@ public abstract class DBColumn extends DBColumnExpr
     { 
         return setAttribute(Column.COLATTR_NORMCOLUMN, normalizedColumn);
     }
+
+    /**
+     * Returns whether or not a column is case sensitive
+     * If not explicitly set, the case sensitivity is true for all text fields (VARCHAR, CLOB) except if an EnumType is set.
+     * @return true if the column is case sensitive or false if not
+     */
+    @Override
+    public boolean isCaseSensitive()
+    {
+        Object value = getAttribute(Column.COLATTR_CASESENSITIVE);
+        if (value==null)
+        {   // default is true for VARCHAR and CLOB except if EnumType is set
+            return getDataType().isText() && (getEnumType()==null);
+        }
+        return ObjectUtils.getBoolean(value);
+    }
+    
+    /**
+     * Sets the case sensitivity of the column
+     * @param caseSensitiv may be true, false or null
+     * @return returns self (this)
+     */
+    public final <T extends DBColumn> T setCaseSensitive(Boolean caseSensitiv)
+    {
+        return setAttribute(Column.COLATTR_CASESENSITIVE, caseSensitiv);
+    }
     
     /**
      * @return the current DBDatabase object