Skip to content

Commit 8e35182

Browse files
authored
CosmosDB Support double partition keys (#698)
1 parent fab3205 commit 8e35182

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

gxcosmosdb/src/main/java/com/genexus/db/cosmosdb/CosmosDBPreparedStatement.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import reactor.core.publisher.Mono;
2323

2424
import java.io.InputStream;
25+
import java.math.BigDecimal;
2526
import java.sql.Connection;
2627
import java.sql.ResultSet;
2728
import java.sql.SQLException;
@@ -399,13 +400,18 @@ private JSONObject setUpJsonPayload(boolean isUpdate) throws JSONException, SQLE
399400
}
400401

401402
private PartitionKey toPartitionKey(Object value) throws Exception {
403+
402404
if (Double.class.isInstance(value))
403405
return new PartitionKey((double)value);
404406
if (value instanceof Boolean)
405407
return new PartitionKey((boolean)value);
406408
if (String.class.isInstance(value))
407409
return new PartitionKey((String)value);
408-
else throw new Exception("Partitionkey can be double, bool or string.");
410+
if (value instanceof BigDecimal) {
411+
Double doubleValue = ((BigDecimal) value).doubleValue();
412+
return new PartitionKey(doubleValue);
413+
}
414+
else throw new Exception("Partitionkey can be double, bool or string.");
409415
}
410416

411417
@Override

0 commit comments

Comments
 (0)