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 05207d3e EMPIREDB-431 DBColumn: new convenience function
coalesceColumn()
05207d3e is described below
commit 05207d3ebdddc078197b97e82af673bc65d4f23d
Author: Rainer Döbele <[email protected]>
AuthorDate: Thu Jan 9 11:49:34 2025 +0100
EMPIREDB-431
DBColumn: new convenience function coalesceColumn()
---
empire-db/src/main/java/org/apache/empire/db/DBColumn.java | 11 +++++++++++
.../src/main/java/org/apache/empire/db/DBColumnExpr.java | 4 ++--
2 files changed, 13 insertions(+), 2 deletions(-)
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 8af9d098..5ff3ae81 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
@@ -356,6 +356,17 @@ public abstract class DBColumn extends DBColumnExpr
return this.as(getAlias());
}
+ /**
+ * Creates a column expression with coalesce and renames it to this column
+ *
+ * @param nullValue the alternative value when this column is null
+ * @return the coalesce and alias expression
+ */
+ public DBColumnExpr coalesceColumn(Object nullValue)
+ {
+ return coalesce(nullValue).as(this);
+ }
+
/**
* @see DBColumnExpr#getAttribute(String)
*/
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java
b/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java
index 25dade4f..acd000bf 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBColumnExpr.java
@@ -675,8 +675,8 @@ public abstract class DBColumnExpr extends DBExpr
/**
* Creates a sql-expression for the nvl() or coalesce() function.
*
- * @param nullValue the Object value
- * @return the new DBFuncExpr object
+ * @param nullValue the alternative value when this expression is null
+ * @return the coalesce expression
*/
public DBColumnExpr coalesce(Object nullValue)
{