Skip to content

Commit

Permalink
CORE-16870 Support nullable parameters in queries (#1417)
Browse files Browse the repository at this point in the history
Right now nullable parameters are not supported in named queries, after this change we'll support setting null parameters. This feature was requested by various teams before.
  • Loading branch information
nkovacsx authored Dec 21, 2023
1 parent a25631f commit c6d34bb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.corda.v5.application.persistence;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Map;

Expand Down Expand Up @@ -54,7 +55,7 @@ public interface ParameterizedQuery<R> extends PagedQuery<R> {
* @return the same {@link ParameterizedQuery} instance.
*/
@NotNull
ParameterizedQuery<R> setParameter(@NotNull String name, @NotNull Object value);
ParameterizedQuery<R> setParameter(@NotNull String name, @Nullable Object value);

/**
* Sets the parameters as a {@link Map}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "parameters",
"type": {
"type": "map",
"values": "bytes"
"values": ["null", "bytes"]
},
"doc": "Parameters for the query, with each value represented as a bytes array payload serialized in AMQP format. Null values must be tested using IS NULL in the query; it is not possible to pass in a null as a parameter value. "
},
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ cordaProductVersion = 5.2.0
# NOTE: update this each time this module contains a breaking change
## NOTE: currently this is a top level revision, so all API versions will line up, but this could be moved to
## a per module property in which case module versions can change independently.
cordaApiRevision = 21
cordaApiRevision = 22

# Main
kotlin.stdlib.default.dependency = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.corda.v5.ledger.utxo.StateAndRef;
import net.corda.v5.ledger.utxo.UtxoLedgerService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.time.Instant;
import java.util.Map;
Expand Down Expand Up @@ -45,7 +46,7 @@ public interface VaultNamedParameterizedQuery<R> extends ParameterizedQuery<R> {
*/
@Override
@NotNull
VaultNamedParameterizedQuery<R> setParameter(@NotNull String name, @NotNull Object value);
VaultNamedParameterizedQuery<R> setParameter(@NotNull String name, @Nullable Object value);

/**
* @see ParameterizedQuery#setParameters(Map)
Expand Down

0 comments on commit c6d34bb

Please sign in to comment.