Skip to content

Commit

Permalink
Merge pull request #37 from VedantMahajanOracle/241104
Browse files Browse the repository at this point in the history
Updating to 241104
  • Loading branch information
morgiyan authored Nov 5, 2024
2 parents a21e6c8 + dd1354c commit 6d7860e
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 99 deletions.
23 changes: 13 additions & 10 deletions orajsoda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,23 @@
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<excludes>
<exclude>**/*.ade_path/**</exclude>
</excludes>
<tasks>
<jar destfile="${project.basedir}/target/orajsoda-sources.jar">
<fileset dir="${project.basedir}/src/main/java"
excludes="**/*.ade_path/**, **/internal/**, **/json/impl/**, **/json/rdbms/**"/>
<fileset dir="${project.basedir}/src/main/resources"
excludes="**/*.ade_path/**, **/internal/**, **/json/impl/**, **/json/rdbms/**"/>
</jar>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Expand Down
13 changes: 11 additions & 2 deletions orajsoda/src/main/java/oracle/json/util/ComponentTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ public static Instant stringToInstant(String isostr)

private static final DateTimeFormatter ISO_FORMATTER =
DateTimeFormatter.ofPattern("YYYY-MM-dd'T'HH:mm:ss.nnnnnnnnn");

private static final DateTimeFormatter ISO_FORMATTER_SIX_DIGITS =
DateTimeFormatter.ofPattern("YYYY-MM-dd'T'HH:mm:ss.SSSSSS");

/**
* Convert an Instant to an ISO 8601 string matching the old
Expand All @@ -243,13 +246,19 @@ public static String instantToString(Instant ival, boolean withZone)
{
return ComponentTime.instantToString(ival, withZone, false);
}

public static String instantToString(Instant ival, boolean withZone, boolean truncateMillis)
{
return ComponentTime.instantToString(ival, withZone, withZone, false);
}

public static String instantToString(Instant ival,
boolean withZone,
boolean truncateMillis)
boolean truncateMillis,
boolean useSixDigits)
{
LocalDateTime dt = LocalDateTime.ofInstant(ival, ZoneOffset.UTC);
String result = dt.format(ISO_FORMATTER);
String result = dt.format(useSixDigits ? ISO_FORMATTER_SIX_DIGITS : ISO_FORMATTER);
if (truncateMillis)
result = result.substring(0, result.indexOf('.'));
else if (result.endsWith("000")) // Remove nanos if they're zero
Expand Down
49 changes: 40 additions & 9 deletions orajsoda/src/main/java/oracle/soda/OracleOperationBuilder.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2014, 2023, Oracle and/or its affiliates. */
/* Copyright (c) 2014, 2024, Oracle and/or its affiliates. */
/* All rights reserved.*/

package oracle.soda;
Expand Down Expand Up @@ -234,10 +234,10 @@ OracleOperationBuilder version(String version)
OracleCursor getCursor() throws OracleException;

/**
* Replaces a document.
* Replaces target document with supplied document.
* <p>
* This method is used in conjunction with <code>key(...)</code>,
* and (optionally) <code>version(...)</code> methods.
* This method is used in conjunction with {@link #key(String) key()}
* and (optionally) {@link #version(String) version()} methods.
* <p>
* For example:
* <pre>
Expand Down Expand Up @@ -268,10 +268,42 @@ OracleDocument replaceOneAndGet(OracleDocument document)
throws OracleException;

/**
* Replaces a document.
* Replaces target document(s) with supplied document.
* <p>
* This method is used in conjunction with <code>key(...)</code>,
* and (optionally) <code>version(...)</code> methods.
* Unlike {@link #replaceOne(OracleDocument) replaceOne()} and
* {@link #replaceOneAndGet(OracleDocument) replaceOneAndGet()} method,
* this method does not require {@link #key(String) key()} method
* to be used in conjunction. Note also: unlike the two "replace one"
* methods mentioned above, this method can replace multiple
* target documents in the collection with the supplied document.
* <p>
* For example:
* <pre>
* // Replace content of documents having field "_id" with value 1,
* // with the content of supplied document d1
* col.find().("{\"_id\" : 1}").replaceOne(d1)
* </pre>
* <p>
* Note that the key and version information (if any) in the input
* document 'd1' is ignored.
* <p>
* This is a terminal method, and, as such, it causes operation
* execution.
*
* @param document input document. Cannot be <code>null</code>
* @return number of documents replaced
* @throws OracleException if (1) the input document is <code>null</code>,
* or (2) there's an error replacing the input
* <code>document</code>
*/
int replace(OracleDocument document)
throws OracleException;

/**
* Replaces target document with supplied document.
* <p>
* This method is used in conjunction with {@link #key(String) key()}
* and (optionally) {@link #version(String) version()} methods.
* <p>
* For example:
* <pre>
Expand Down Expand Up @@ -316,8 +348,7 @@ boolean replaceOne(OracleDocument document)
* execution.
* @exception OracleException if an error during removal occurs
*
* @return count of the number of documents
* removed
* @return number of documents removed
*/
int remove()
throws OracleException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,8 @@ public String extractKeyForEmbeddedIdEJSONCollections(OracleDocument document,
public String extractKeyForEmbeddedIdCollections(DocumentCodec keyProcessor,
OracleDocument document,
boolean eJSON,
String key)
String key,
boolean skipCanonicalKeyCheck)
throws OracleException {

String dockey = key;
Expand Down Expand Up @@ -978,7 +979,10 @@ public String extractKeyForEmbeddedIdCollections(DocumentCodec keyProcessor,

// If we found a key, validate it and then use it
if (dockey != null)
return canonicalKey(dockey);
if (!skipCanonicalKeyCheck)
return canonicalKey(dockey);
else
return dockey;
}

return null;
Expand Down Expand Up @@ -1067,10 +1071,10 @@ protected Pair<String, Object> getDocumentKey(OracleDocument document, boolean g
dockeySteps = initializeDocumentKeySteps();
keyProcessor.setKeyPath(dockeySteps);

String extractedKey = extractKeyForEmbeddedIdCollections(keyProcessor, document, eJSON, dockey);
String extractedKey = extractKeyForEmbeddedIdCollections(keyProcessor, document, eJSON, dockey, options.hasMaterializedEmbeddedID());

if (extractedKey != null)
return new Pair<String, Object>(canonicalKey(extractedKey), null);
return new Pair<String, Object>(extractedKey, null);


// See if the key needs to be generated for auto-insertion
Expand Down
Loading

0 comments on commit 6d7860e

Please sign in to comment.