Skip to content

Commit

Permalink
add a lock file
Browse files Browse the repository at this point in the history
  • Loading branch information
evanchooly committed Jun 19, 2024
1 parent b1b98d8 commit b48d354
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
12 changes: 9 additions & 3 deletions core/src/test/java/dev/morphia/test/TemplatedTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import dev.morphia.query.FindOptions;
import dev.morphia.query.MorphiaQuery;

import org.bson.BsonInvalidOperationException;
import org.bson.Document;
import org.bson.codecs.DecoderContext;
import org.bson.json.JsonParseException;
Expand Down Expand Up @@ -299,7 +300,8 @@ protected String loadResource(String pipelineName) {
return resource;
}

private List<Document> extractDocuments(String line) {
private List<Document> extractDocuments(String resource) {
var line = resource;
if (line.startsWith("db.")) {
if (line.endsWith(")")) {
line = line.substring(line.indexOf("(") + 1, line.lastIndexOf(")")).trim();
Expand All @@ -313,7 +315,11 @@ private List<Document> extractDocuments(String line) {
char c = line.charAt(0);
line = line.substring(1);
if (balanced(current)) {
docs.add(Document.parse(current));
try {
docs.add(Document.parse(current));
} catch (BsonInvalidOperationException e) {
throw new RuntimeException("Error parsing " + resource, e);
}
current = "";
} else {
current += c;
Expand All @@ -340,7 +346,7 @@ private void extractQueryFilters(List<String> list) {
}

private static String unwrapArray(String resource) {
String line = resource;
String line = resource.trim();
if (line.startsWith("[")) {
line = line.substring(1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
db.donors.updateMany(
{},
[
{ $set:
{ amount:
{ $floor:
{ $multiply: [ { $rand: {} }, 100 ] }
}
}
}
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
unwrap the operators from the array

0 comments on commit b48d354

Please sign in to comment.