Skip to content

Commit ec57410

Browse files
authored
fix: params are not correct when using rawSql in sub query (#41)
* fix: params are not correct when using rawSql in sub query * fix: params are not correct when using rawSql in sub query, bump versin
1 parent 0357e81 commit ec57410

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ java-cosmos is a client for Azure CosmosDB 's SQL API (also called documentdb fo
2929
<dependency>
3030
<groupId>com.github.thunderz99</groupId>
3131
<artifactId>java-cosmos</artifactId>
32-
<version>0.2.21</version>
32+
<version>0.2.22</version>
3333
</dependency>
3434

3535
```

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.github.thunderz99</groupId>
55
<artifactId>java-cosmos</artifactId>
66
<packaging>jar</packaging>
7-
<version>0.2.21</version>
7+
<version>0.2.22</version>
88
<name>${project.groupId}:${project.artifactId}$</name>
99
<description>A lightweight Azure CosmosDB client for Java</description>
1010
<url>https://github.com/thunderz99/java-cosmos</url>

src/main/java/io/github/thunderz99/cosmos/condition/Condition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ FilterQuery generateFilterQuery(String selectPart, SqlParameterCollection params
322322
params.addAll(this.rawQuerySpec.getParameters());
323323
String rawQueryText = processNegativeQuery(this.rawQuerySpec.getQueryText(), this.negative);
324324
return new FilterQuery(rawQueryText,
325-
this.rawQuerySpec.getParameters(), conditionIndex, paramIndex);
325+
params, conditionIndex, paramIndex);
326326
}
327327

328328
// process filters

src/test/java/io/github/thunderz99/cosmos/condition/ConditionTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,5 +784,26 @@ public void processNegativeQuery_should_work() {
784784

785785
}
786786

787+
@Test
788+
public void true_condition_in_subquery_should_work() {
789+
790+
var cond1 = Condition.trueCondition();
791+
var cond2 = Condition.filter("id", "001");
792+
793+
var cond = Condition.filter(SubConditionType.SUB_COND_AND, List.of(cond1, cond2));
794+
795+
var q = cond.toQuerySpec();
796+
797+
assertThat(q.getQueryText()).isEqualTo("SELECT * FROM c WHERE (1=1 AND (c[\"id\"] = @param000_id)) OFFSET 0 LIMIT 100");
798+
799+
var params = List.copyOf(q.getParameters());
800+
801+
assertThat(params).hasSize(1);
802+
803+
assertThat(params.get(0).toJson()).isEqualTo(new SqlParameter("@param000_id", "001").toJson());
804+
805+
806+
}
807+
787808

788809
}

0 commit comments

Comments
 (0)