Skip to content

Commit 5506714

Browse files
committed
HHH-17355 Rename array_contains_any to array_overlaps
1 parent 3e0feab commit 5506714

File tree

15 files changed

+101
-118
lines changed

15 files changed

+101
-118
lines changed

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

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,17 +1118,15 @@ The following functions deal with SQL array types, which are not supported on ev
11181118
| Function | Purpose
11191119
11201120
| `array()` | Creates an array based on the passed arguments
1121-
| `array_contains()` | Whether an array contains an element
1122-
| `array_contains_null()` | Whether an array contains a null
11231121
| `array_position()` | Determines the position of an element in an array
11241122
| `array_length()` | Determines the length of an array
11251123
| `array_concat()` | Concatenates array with each other in order
11261124
| `array_prepend()` | Prepends element to array
11271125
| `array_append()` | Appends element to array
1128-
| `array_contains_all()` | Determines if one array holds all elements of another array
1129-
| `array_contains_all_nullable()` | Determines if one array holds all elements of another array, supporting null elements
1130-
| `array_contains_any()` | Determines if one array holds at least one element of another array
1131-
| `array_contains_any_nullable()` | Determines if one array holds at least one element of another array, supporting null elements
1126+
| `array_contains()` | Whether an array contains element(s)
1127+
| `array_contains_nullable()` | Whether an array contains element(s), supporting `null` elements
1128+
| `array_overlaps()` | Whether an array holds at least one element of another array
1129+
| `array_overlaps_nullable()` | Whether an array holds at least one element of another array, supporting `null` elements
11321130
| `array_get()` | Accesses the element of an array by index
11331131
| `array_set()` | Creates array copy with given element at given index
11341132
| `array_remove()` | Creates array copy with given element removed
@@ -1148,25 +1146,6 @@ include::{array-example-dir-hql}/ArrayConstructorTest.java[tags=hql-array-exampl
11481146
----
11491147
====
11501148
1151-
[[hql-array-contains-functions]]
1152-
===== `array_contains()` and `array_contains_null()`
1153-
1154-
Both functions return `null` if the first argument, the array, is null, yet the result of the `array_contains` function
1155-
is undefined when the second argument, the element to search, is `null`.
1156-
The `array_contains_null` function only takes a single argument, the array, and will return whether the array contains a `null` element.
1157-
1158-
[[hql-array-contains-example]]
1159-
====
1160-
[source, JAVA, indent=0]
1161-
----
1162-
include::{array-example-dir-hql}/ArrayContainsTest.java[tags=hql-array-contains-example]
1163-
----
1164-
[source, JAVA, indent=0]
1165-
----
1166-
include::{array-example-dir-hql}/ArrayContainsTest.java[tags=hql-array-contains-null-example]
1167-
----
1168-
====
1169-
11701149
[[hql-array-position-functions]]
11711150
===== `array_position()`
11721151
@@ -1232,49 +1211,63 @@ include::{array-example-dir-hql}/ArrayAppendTest.java[tags=hql-array-append-exam
12321211
----
12331212
====
12341213
1235-
[[hql-array-contains-quantified-functions]]
1236-
===== `array_contains_all()` and `array_contains_any()`
1214+
[[hql-array-contains-functions]]
1215+
===== `array_contains()` and `array_contains_nullable()`
1216+
1217+
Checks if the first array argument contains the element(s) of the second argument.
1218+
Returns `null` if the first argument is `null`. The result of the `array_contains` function
1219+
is undefined when the second argument, the element to search, is `null`.
1220+
1221+
[[hql-array-contains-example]]
1222+
====
1223+
[source, JAVA, indent=0]
1224+
----
1225+
include::{array-example-dir-hql}/ArrayContainsTest.java[tags=hql-array-contains-example]
1226+
----
1227+
====
12371228
1238-
Checks if the first array argument contains all or any of the elements of the second array argument.
1239-
Returns `null` if either of the arguments is `null`. The result of the functions
1240-
is undefined when the second array argument contains a `null`.
1229+
The second argument may be an array of the same type as the first argument.
1230+
The result of `array_contains` is undefined when the second argument is an array that contains a `null` element.
12411231
1242-
[[hql-array-contains-all-example]]
1232+
[[hql-array-contains-array-example]]
12431233
====
12441234
[source, JAVA, indent=0]
12451235
----
12461236
include::{array-example-dir-hql}/ArrayContainsAllTest.java[tags=hql-array-contains-all-example]
12471237
----
12481238
====
12491239
1250-
[[hql-array-contains-any-example]]
1240+
To search for `null` elements, the `array_contains_nullable` function must be used with an array argument.
1241+
1242+
[[hql-array-contains-array-nullable-example]]
12511243
====
12521244
[source, JAVA, indent=0]
12531245
----
1254-
include::{array-example-dir-hql}/ArrayContainsAnyTest.java[tags=hql-array-contains-any-example]
1246+
include::{array-example-dir-hql}/ArrayContainsAllTest.java[tags=hql-array-contains-all-nullable-example]
12551247
----
12561248
====
12571249
1258-
[[hql-array-contains-quantified-functions]]
1259-
===== `array_contains_all_nullable()` & `array_contains_any_nullable()`
1250+
[[hql-array-overlaps-functions]]
1251+
===== `array_overlaps()` and `array_overlaps_nullable()`
12601252
1261-
Checks if the first array argument contains all or any of the elements of the second array argument.
1262-
Returns `null` if either of the arguments is `null`. Contrary to `array_contains_all()` and `array_contains_any()`,
1263-
these functions use the `distinct from` operator to also support searching for `null` elements.
1253+
Checks if the first array argument any of the elements of the second array argument.
1254+
Returns `null` if either of the arguments is `null`. The result of `array_overlaps`
1255+
is undefined when the second array argument contains a `null` array element.
1256+
Only `array_overlaps_nullable` is guaranteed to produce correct results for `null` array elements.
12641257
1265-
[[hql-array-contains-all-nullable-example]]
1258+
[[hql-array-overlaps-example]]
12661259
====
12671260
[source, JAVA, indent=0]
12681261
----
1269-
include::{array-example-dir-hql}/ArrayContainsAllTest.java[tags=hql-array-contains-all-nullable-example]
1262+
include::{array-example-dir-hql}/ArrayOverlapsTest.java[tags=hql-array-overlaps-example]
12701263
----
12711264
====
12721265
1273-
[[hql-array-contains-any-nullable-example]]
1266+
[[hql-array-overlaps-nullable-example]]
12741267
====
12751268
[source, JAVA, indent=0]
12761269
----
1277-
include::{array-example-dir-hql}/ArrayContainsAnyTest.java[tags=hql-array-contains-any-nullable-example]
1270+
include::{array-example-dir-hql}/ArrayOverlapsTest.java[tags=hql-array-overlaps-nullable-example]
12781271
----
12791272
====
12801273

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,9 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
471471
functionFactory.arrayPrepend_postgresql();
472472
functionFactory.arrayAppend_postgresql();
473473
functionFactory.arrayContainsAll_operator();
474-
functionFactory.arrayContainsAny_operator();
474+
functionFactory.arrayOverlaps_operator();
475475
functionFactory.arrayContainsAllNullable_operator();
476-
functionFactory.arrayContainsAnyNullable_operator();
476+
functionFactory.arrayOverlapsNullable_unnest();
477477
functionFactory.arrayGet_bracket();
478478
functionFactory.arraySet_unnest();
479479
functionFactory.arrayRemove();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,9 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
379379
functionFactory.arrayPrepend_operator();
380380
functionFactory.arrayAppend_operator();
381381
functionFactory.arrayContainsAll_h2();
382-
functionFactory.arrayContainsAny_h2();
382+
functionFactory.arrayOverlaps_h2();
383383
functionFactory.arrayContainsAllNullable_h2();
384-
functionFactory.arrayContainsAnyNullable_h2();
384+
functionFactory.arrayOverlapsNullable_h2();
385385
functionFactory.arrayGet_h2();
386386
functionFactory.arraySet_h2();
387387
functionFactory.arrayRemove_h2();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
257257
functionFactory.arrayPrepend_operator();
258258
functionFactory.arrayAppend_operator();
259259
functionFactory.arrayContainsAll_hsql();
260-
functionFactory.arrayContainsAny_hsql();
260+
functionFactory.arrayOverlaps_hsql();
261261
functionFactory.arrayContainsAllNullable_hsql();
262-
functionFactory.arrayContainsAnyNullable_hsql();
262+
functionFactory.arrayOverlapsNullable_unnest();
263263
functionFactory.arrayGet_unnest();
264264
functionFactory.arraySet_hsql();
265265
functionFactory.arrayRemove_hsql();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
293293
functionFactory.arrayPrepend_oracle();
294294
functionFactory.arrayAppend_oracle();
295295
functionFactory.arrayContainsAll_oracle();
296-
functionFactory.arrayContainsAny_oracle();
296+
functionFactory.arrayOverlaps_oracle();
297297
functionFactory.arrayContainsAllNullable_oracle();
298-
functionFactory.arrayContainsAnyNullable_oracle();
298+
functionFactory.arrayOverlapsNullable_oracle();
299299
functionFactory.arrayGet_oracle();
300300
functionFactory.arraySet_oracle();
301301
functionFactory.arrayRemove_oracle();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,9 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
591591
functionFactory.arrayPrepend_postgresql();
592592
functionFactory.arrayAppend_postgresql();
593593
functionFactory.arrayContainsAll_operator();
594-
functionFactory.arrayContainsAny_operator();
594+
functionFactory.arrayOverlaps_operator();
595595
functionFactory.arrayContainsAllNullable_operator();
596-
functionFactory.arrayContainsAnyNullable_operator();
596+
functionFactory.arrayOverlapsNullable_unnest();
597597
functionFactory.arrayGet_bracket();
598598
functionFactory.arraySet_unnest();
599599
functionFactory.arrayRemove();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,9 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
458458
functionFactory.arrayPrepend_postgresql();
459459
functionFactory.arrayAppend_postgresql();
460460
functionFactory.arrayContainsAll_operator();
461-
functionFactory.arrayContainsAny_operator();
461+
functionFactory.arrayOverlaps_operator();
462462
functionFactory.arrayContainsAllNullable_operator();
463-
functionFactory.arrayContainsAnyNullable_operator();
463+
functionFactory.arrayOverlapsNullable_unnest();
464464
functionFactory.arrayGet_bracket();
465465
functionFactory.arraySet_unnest();
466466
functionFactory.arrayRemove();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
318318
functionFactory.arrayPrepend_operator();
319319
functionFactory.arrayAppend_operator();
320320
functionFactory.arrayContainsAll_h2();
321-
functionFactory.arrayContainsAny_h2();
321+
functionFactory.arrayOverlaps_h2();
322322
functionFactory.arrayContainsAllNullable_h2();
323-
functionFactory.arrayContainsAnyNullable_h2();
323+
functionFactory.arrayOverlapsNullable_h2();
324324
functionFactory.arrayGet_h2();
325325
functionFactory.arraySet_h2();
326326
functionFactory.arrayRemove_h2();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
197197
functionFactory.arrayPrepend_operator();
198198
functionFactory.arrayAppend_operator();
199199
functionFactory.arrayContainsAll_hsql();
200-
functionFactory.arrayContainsAny_hsql();
200+
functionFactory.arrayOverlaps_hsql();
201201
functionFactory.arrayContainsAllNullable_hsql();
202-
functionFactory.arrayContainsAnyNullable_hsql();
202+
functionFactory.arrayOverlapsNullable_unnest();
203203
functionFactory.arrayGet_unnest();
204204
functionFactory.arraySet_hsql();
205205
functionFactory.arrayRemove_hsql();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,10 @@ public void addAuxiliaryDatabaseObjects(
307307
);
308308
database.addAuxiliaryDatabaseObject(
309309
new NamedAuxiliaryDatabaseObject(
310-
arrayTypeName + "_contains_any",
310+
arrayTypeName + "_overlaps",
311311
database.getDefaultNamespace(),
312312
new String[]{
313-
"create or replace function " + arrayTypeName + "_contains_any(haystack in " + arrayTypeName +
313+
"create or replace function " + arrayTypeName + "_overlaps(haystack in " + arrayTypeName +
314314
", needle in " + arrayTypeName + ", nullable in number) return number deterministic is begin " +
315315
"if haystack is null or needle is null then return null; end if; " +
316316
"if needle.count = 0 then return 1; end if; " +
@@ -322,7 +322,7 @@ public void addAuxiliaryDatabaseObjects(
322322
"return 0; " +
323323
"end;"
324324
},
325-
new String[] { "drop function " + arrayTypeName + "_contains_any" },
325+
new String[] { "drop function " + arrayTypeName + "_overlaps" },
326326
emptySet(),
327327
false
328328
)

0 commit comments

Comments
 (0)