Skip to content

Commit 36066a0

Browse files
committed
HHH-18604 Add json_remove function and fix some Oracle functions
1 parent 17f3286 commit 36066a0

27 files changed

+527
-4
lines changed

documentation/src/main/asciidoc/userguide/chapters/query/hql/QueryLanguage.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,7 @@ it is necessary to enable the `hibernate.query.hql.json_functions_enabled` confi
16401640
| `json_arrayagg()` | Creates a JSON array by aggregating values
16411641
| `json_objectagg()` | Creates a JSON object by aggregating values
16421642
| `json_set()` | Inserts/Replaces a value by JSON path within a JSON document
1643+
| `json_remove()` | Removes a value by JSON path within a JSON document
16431644
|===
16441645
16451646
@@ -2030,6 +2031,22 @@ include::{json-example-dir-hql}/JsonSetTest.java[tags=hql-json-set-example]
20302031
20312032
WARNING: SAP HANA, DB2, H2 and HSQLDB do not support this function.
20322033
2034+
[[hql-json-remove-function]]
2035+
===== `json_remove()`
2036+
2037+
Removes a value by JSON path within a JSON document.
2038+
The function takes 2 arguments, the json document and the json path representing what to remove.
2039+
2040+
[[hql-json-remove-example]]
2041+
====
2042+
[source, java, indent=0]
2043+
----
2044+
include::{json-example-dir-hql}/JsonRemoveTest.java[tags=hql-json-remove-example]
2045+
----
2046+
====
2047+
2048+
WARNING: SAP HANA, DB2, H2 and HSQLDB do not support this function.
2049+
20332050
[[hql-user-defined-functions]]
20342051
==== Native and user-defined functions
20352052

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CockroachLegacyDialect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
509509
functionFactory.jsonArrayAgg_postgresql( false );
510510
functionFactory.jsonObjectAgg_postgresql( false );
511511
functionFactory.jsonSet_postgresql();
512+
functionFactory.jsonRemove_postgresql();
512513

513514
// Postgres uses # instead of ^ for XOR
514515
functionContributions.getFunctionRegistry().patternDescriptorBuilder( "bitxor", "(?1#?2)" )

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MySQLLegacyDialect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
661661
functionFactory.jsonArrayAgg_mysql();
662662
functionFactory.jsonObjectAgg_mysql();
663663
functionFactory.jsonSet_mysql();
664+
functionFactory.jsonRemove_mysql();
664665
}
665666
}
666667

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/OracleLegacyDialect.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
316316
functionFactory.jsonObject_oracle();
317317
functionFactory.jsonArray_oracle();
318318
functionFactory.jsonArrayAgg_oracle();
319+
functionFactory.jsonObjectAgg_oracle();
319320
functionFactory.jsonSet_oracle();
321+
functionFactory.jsonRemove_oracle();
320322
}
321323
}
322324

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/PostgreSQLLegacyDialect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
659659
}
660660
}
661661
functionFactory.jsonSet_postgresql();
662+
functionFactory.jsonRemove_postgresql();
662663

663664
if ( getVersion().isSameOrAfter( 9, 4 ) ) {
664665
functionFactory.makeDateTimeTimestamp();

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLServerLegacyDialect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
407407
functionFactory.jsonObject_sqlserver();
408408
functionFactory.jsonArray_sqlserver();
409409
functionFactory.jsonSet_sqlserver();
410+
functionFactory.jsonRemove_sqlserver();
410411
}
411412
if ( getVersion().isSameOrAfter( 14 ) ) {
412413
functionFactory.listagg_stringAggWithinGroup( "varchar(max)" );

hibernate-core/src/main/java/org/hibernate/dialect/CockroachDialect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
476476
functionFactory.jsonArrayAgg_postgresql( false );
477477
functionFactory.jsonObjectAgg_postgresql( false );
478478
functionFactory.jsonSet_postgresql();
479+
functionFactory.jsonRemove_postgresql();
479480

480481
// Postgres uses # instead of ^ for XOR
481482
functionContributions.getFunctionRegistry().patternDescriptorBuilder( "bitxor", "(?1#?2)" )

hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
646646
functionFactory.jsonArrayAgg_mysql();
647647
functionFactory.jsonObjectAgg_mysql();
648648
functionFactory.jsonSet_mysql();
649+
functionFactory.jsonRemove_mysql();
649650
}
650651

651652
@Override

hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
407407
functionFactory.jsonObject_oracle();
408408
functionFactory.jsonArray_oracle();
409409
functionFactory.jsonArrayAgg_oracle();
410+
functionFactory.jsonObjectAgg_oracle();
410411
functionFactory.jsonSet_oracle();
412+
functionFactory.jsonRemove_oracle();
411413
}
412414

413415
@Override

hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
620620
}
621621
}
622622
functionFactory.jsonSet_postgresql();
623+
functionFactory.jsonRemove_postgresql();
623624

624625
functionFactory.makeDateTimeTimestamp();
625626
// Note that PostgreSQL doesn't support the OVER clause for ordered set-aggregate functions

0 commit comments

Comments
 (0)