File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
main/java/oracle/nosql/driver
test/java/oracle/nosql/driver Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ query in an iterable/iterator format. The returned QueryIterableResult should
1010be used in a try-with-resources statement to ensure proper closing of
1111resources.
1212- updated NoSQLHandle and QueryRequest interfaces to extend AutoClosable
13+ - added Version.createVersion(byte[ ] ) to allow creation of a Version object from a
14+ query that returns row_version() as a BinaryValue. The Version can be used for
15+ conditional put and delete operations
1316- added support for setting an extension to the User Agent http header by
1417setting the ExtensionUserAgent property on NoSQLHandlerConfig.
1518
Original file line number Diff line number Diff line change @@ -37,7 +37,10 @@ public byte[] getBytes() {
3737 }
3838
3939 /**
40- * @hidden
40+ * Creates a Version instance from a byte[] which may have been acquired
41+ * from a query using the row_version() function which returns a FieldValue
42+ * of type BINARY.
43+ *
4144 * @param version the version to use
4245 * @return a new Version instance
4346 */
Original file line number Diff line number Diff line change @@ -797,6 +797,27 @@ public void testPutGetDelete() {
797797 (serialVersion > 2 ), /* modtime should be recent */
798798 recordKB );
799799
800+ /* save this for comparison below */
801+ Version version = getRes .getVersion ();
802+
803+ /*
804+ * get the row version of the same row using a query and assert
805+ * that the versions are the same. A test could be created to use this
806+ * in a condition put/delete operation but that functionality is already
807+ * tested. This just ensures that the versions acquired from get()
808+ * and from row_version are identical
809+ */
810+ try (QueryRequest queryReq = new QueryRequest ()) {
811+ final String versionQuery = "select row_version($t) as version " +
812+ "from " + tableName + " $t where id = 10" ;
813+ queryReq .setStatement (versionQuery );
814+ QueryResult queryRet = handle .query (queryReq );
815+ MapValue result = queryRet .getResults ().get (0 );
816+ Version qVersion = Version .createVersion (
817+ result .get ("version" ).asBinary ().getValue ());
818+ assertArrayEquals (version .getBytes (), qVersion .getBytes ());
819+ }
820+
800821 /* Get a row with ABSOLUTE consistency */
801822 getReq .setConsistency (Consistency .ABSOLUTE );
802823 getRes = handle .get (getReq );
You can’t perform that action at this time.
0 commit comments