Skip to content

Commit 6d7860e

Browse files
authored
Merge pull request #37 from VedantMahajanOracle/241104
Updating to 241104
2 parents a21e6c8 + dd1354c commit 6d7860e

File tree

8 files changed

+178
-99
lines changed

8 files changed

+178
-99
lines changed

orajsoda/pom.xml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,23 @@
5050
<finalName>${project.artifactId}</finalName>
5151
<plugins>
5252
<plugin>
53-
<groupId>org.apache.maven.plugins</groupId>
54-
<artifactId>maven-source-plugin</artifactId>
55-
<version>3.2.1</version>
53+
<artifactId>maven-antrun-plugin</artifactId>
5654
<executions>
5755
<execution>
58-
<id>attach-sources</id>
59-
<goals>
60-
<goal>jar</goal>
61-
</goals>
56+
<phase>process-resources</phase>
6257
<configuration>
63-
<excludes>
64-
<exclude>**/*.ade_path/**</exclude>
65-
</excludes>
58+
<tasks>
59+
<jar destfile="${project.basedir}/target/orajsoda-sources.jar">
60+
<fileset dir="${project.basedir}/src/main/java"
61+
excludes="**/*.ade_path/**, **/internal/**, **/json/impl/**, **/json/rdbms/**"/>
62+
<fileset dir="${project.basedir}/src/main/resources"
63+
excludes="**/*.ade_path/**, **/internal/**, **/json/impl/**, **/json/rdbms/**"/>
64+
</jar>
65+
</tasks>
6666
</configuration>
67+
<goals>
68+
<goal>run</goal>
69+
</goals>
6770
</execution>
6871
</executions>
6972
</plugin>

orajsoda/src/main/java/oracle/json/util/ComponentTime.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ public static Instant stringToInstant(String isostr)
223223

224224
private static final DateTimeFormatter ISO_FORMATTER =
225225
DateTimeFormatter.ofPattern("YYYY-MM-dd'T'HH:mm:ss.nnnnnnnnn");
226+
227+
private static final DateTimeFormatter ISO_FORMATTER_SIX_DIGITS =
228+
DateTimeFormatter.ofPattern("YYYY-MM-dd'T'HH:mm:ss.SSSSSS");
226229

227230
/**
228231
* Convert an Instant to an ISO 8601 string matching the old
@@ -243,13 +246,19 @@ public static String instantToString(Instant ival, boolean withZone)
243246
{
244247
return ComponentTime.instantToString(ival, withZone, false);
245248
}
249+
250+
public static String instantToString(Instant ival, boolean withZone, boolean truncateMillis)
251+
{
252+
return ComponentTime.instantToString(ival, withZone, withZone, false);
253+
}
246254

247255
public static String instantToString(Instant ival,
248256
boolean withZone,
249-
boolean truncateMillis)
257+
boolean truncateMillis,
258+
boolean useSixDigits)
250259
{
251260
LocalDateTime dt = LocalDateTime.ofInstant(ival, ZoneOffset.UTC);
252-
String result = dt.format(ISO_FORMATTER);
261+
String result = dt.format(useSixDigits ? ISO_FORMATTER_SIX_DIGITS : ISO_FORMATTER);
253262
if (truncateMillis)
254263
result = result.substring(0, result.indexOf('.'));
255264
else if (result.endsWith("000")) // Remove nanos if they're zero

orajsoda/src/main/java/oracle/soda/OracleOperationBuilder.java

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2014, 2023, Oracle and/or its affiliates. */
1+
/* Copyright (c) 2014, 2024, Oracle and/or its affiliates. */
22
/* All rights reserved.*/
33

44
package oracle.soda;
@@ -234,10 +234,10 @@ OracleOperationBuilder version(String version)
234234
OracleCursor getCursor() throws OracleException;
235235

236236
/**
237-
* Replaces a document.
237+
* Replaces target document with supplied document.
238238
* <p>
239-
* This method is used in conjunction with <code>key(...)</code>,
240-
* and (optionally) <code>version(...)</code> methods.
239+
* This method is used in conjunction with {@link #key(String) key()}
240+
* and (optionally) {@link #version(String) version()} methods.
241241
* <p>
242242
* For example:
243243
* <pre>
@@ -268,10 +268,42 @@ OracleDocument replaceOneAndGet(OracleDocument document)
268268
throws OracleException;
269269

270270
/**
271-
* Replaces a document.
271+
* Replaces target document(s) with supplied document.
272272
* <p>
273-
* This method is used in conjunction with <code>key(...)</code>,
274-
* and (optionally) <code>version(...)</code> methods.
273+
* Unlike {@link #replaceOne(OracleDocument) replaceOne()} and
274+
* {@link #replaceOneAndGet(OracleDocument) replaceOneAndGet()} method,
275+
* this method does not require {@link #key(String) key()} method
276+
* to be used in conjunction. Note also: unlike the two "replace one"
277+
* methods mentioned above, this method can replace multiple
278+
* target documents in the collection with the supplied document.
279+
* <p>
280+
* For example:
281+
* <pre>
282+
* // Replace content of documents having field "_id" with value 1,
283+
* // with the content of supplied document d1
284+
* col.find().("{\"_id\" : 1}").replaceOne(d1)
285+
* </pre>
286+
* <p>
287+
* Note that the key and version information (if any) in the input
288+
* document 'd1' is ignored.
289+
* <p>
290+
* This is a terminal method, and, as such, it causes operation
291+
* execution.
292+
*
293+
* @param document input document. Cannot be <code>null</code>
294+
* @return number of documents replaced
295+
* @throws OracleException if (1) the input document is <code>null</code>,
296+
* or (2) there's an error replacing the input
297+
* <code>document</code>
298+
*/
299+
int replace(OracleDocument document)
300+
throws OracleException;
301+
302+
/**
303+
* Replaces target document with supplied document.
304+
* <p>
305+
* This method is used in conjunction with {@link #key(String) key()}
306+
* and (optionally) {@link #version(String) version()} methods.
275307
* <p>
276308
* For example:
277309
* <pre>
@@ -316,8 +348,7 @@ boolean replaceOne(OracleDocument document)
316348
* execution.
317349
* @exception OracleException if an error during removal occurs
318350
*
319-
* @return count of the number of documents
320-
* removed
351+
* @return number of documents removed
321352
*/
322353
int remove()
323354
throws OracleException;

orajsoda/src/main/java/oracle/soda/rdbms/impl/OracleCollectionImpl.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,8 @@ public String extractKeyForEmbeddedIdEJSONCollections(OracleDocument document,
926926
public String extractKeyForEmbeddedIdCollections(DocumentCodec keyProcessor,
927927
OracleDocument document,
928928
boolean eJSON,
929-
String key)
929+
String key,
930+
boolean skipCanonicalKeyCheck)
930931
throws OracleException {
931932

932933
String dockey = key;
@@ -978,7 +979,10 @@ public String extractKeyForEmbeddedIdCollections(DocumentCodec keyProcessor,
978979

979980
// If we found a key, validate it and then use it
980981
if (dockey != null)
981-
return canonicalKey(dockey);
982+
if (!skipCanonicalKeyCheck)
983+
return canonicalKey(dockey);
984+
else
985+
return dockey;
982986
}
983987

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

1070-
String extractedKey = extractKeyForEmbeddedIdCollections(keyProcessor, document, eJSON, dockey);
1074+
String extractedKey = extractKeyForEmbeddedIdCollections(keyProcessor, document, eJSON, dockey, options.hasMaterializedEmbeddedID());
10711075

10721076
if (extractedKey != null)
1073-
return new Pair<String, Object>(canonicalKey(extractedKey), null);
1077+
return new Pair<String, Object>(extractedKey, null);
10741078

10751079

10761080
// See if the key needs to be generated for auto-insertion

0 commit comments

Comments
 (0)