Skip to content

Commit

Permalink
Fix query with boolean value (needs JSQLParser 5.1-SNAPSHOT until the…
Browse files Browse the repository at this point in the history
… release of version 5.1)
  • Loading branch information
lucarota committed Nov 27, 2024
1 parent 5e857ef commit 86bd663
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 9 deletions.
23 changes: 19 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>1.6.12-release</revision>
<revision>1.6.13-release</revision>

<!-- Remember to also update ForceService.DEFAULT_API_VERSION -->
<force-partner-api.version>61.1.0</force-partner-api.version>
<lombok.version>1.18.30</lombok.version>
<slf4j.version>2.0.7</slf4j.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<jsqlparser.version>5.0</jsqlparser.version>
<jsqlparser.version>5.1-SNAPSHOT</jsqlparser.version>
<ehcache.version>3.10.8</ehcache.version>
<junit.version>5.9.3</junit.version>
<mockito.version>5.7.0</mockito.version>
Expand All @@ -54,8 +54,17 @@
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<maven-assembly-plugin.version>3.6.0</maven-assembly-plugin.version>
<maven-deploy-plugin.version>3.1.1</maven-deploy-plugin.version>
<unit-platform-launcher.version>1.9.3</unit-platform-launcher.version>
</properties>

<repositories>
<repository>
<id>jsqlparser-snapshots</id>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down Expand Up @@ -133,6 +142,12 @@
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${unit-platform-launcher.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -194,7 +209,7 @@
<profile>
<id>single-jar</id>
<properties>
<revision>1.6.12-fatjar-release</revision>
<revision>1.6.13-fatjar-release</revision>
</properties>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,30 @@ public <S> Expression visit(NullValue nullValue, S context) {
return null;
}

@Override
public <S> Expression visit(BooleanValue booleanValue, S context) {
log.trace("[VtoSVisitor] DoubleValue {}={}", columnName, booleanValue.getValue());
fieldValues.put(columnName, booleanValue.getValue());
return null;
}

@Override
public <S> Expression visit(DoubleValue doubleValue, S context) {
log.warn("[VtoSVisitor] DoubleValue {}={}", columnName, doubleValue.getValue());
log.trace("[VtoSVisitor] DoubleValue {}={}", columnName, doubleValue.getValue());
fieldValues.put(columnName, doubleValue.getValue());
return null;
}

@Override
public <S> Expression visit(LongValue longValue, S context) {
log.warn("[VtoSVisitor] LongValue {}={}", columnName, longValue.getValue());
log.trace("[VtoSVisitor] LongValue {}={}", columnName, longValue.getValue());
fieldValues.put(columnName, longValue.getValue());
return null;
}

@Override
public <S> Expression visit(HexValue hexValue, S context) {
log.warn("[VtoSVisitor] HexValue {}={}", columnName, hexValue.getValue());
log.trace("[VtoSVisitor] HexValue {}={}", columnName, hexValue.getValue());
fieldValues.put(columnName, hexValue.getValue());
return null;
}
Expand All @@ -72,7 +79,7 @@ public <S> Expression visit(Select subSelect, S context) {
Object value = null;
PlainSelect plainSelect = subSelect.getPlainSelect();
if (plainSelect != null) {
log.trace("[VtoxSVisitor] SubSelect {}={}", columnName, plainSelect);
log.trace("[VtoSVisitor] SubSelect {}={}", columnName, plainSelect);
if (subSelectResolver != null) {
List<Map<String, Object>> records = subSelectResolver.apply(plainSelect.toString(), parameters);
if (records.size() == 1 && records.get(0).size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ private Constants() {

public static final int DRIVER_MAJOR_VER = 1;
public static final int DRIVER_MINOR_VER = 6;
public static final int DRIVER_REVISION_VER = 12;
public static final int DRIVER_REVISION_VER = 13;

public static final String DRIVER_VERSION = DRIVER_MAJOR_VER + "." + DRIVER_MINOR_VER + "." + DRIVER_REVISION_VER;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ascendix.jdbc.salesforce.statement.processor;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -261,4 +262,24 @@ void testProcessUpdate_One_All() {
assertEquals("FirstAccount_new", rec.get("Name"));
assertEquals("005xx1111111111111", rec.get("Id"));
}

@Test
void testProcessUpdate_Boolean_ById() {
String soql = "Update Account set Name ='FirstAccount_new', IsDeleted=true where Id='001xx000003GeY0AAK'";
final QueryAnalyzer queryAnalyzer = new QueryAnalyzer(soql, null, null);
UpdateQueryAnalyzer analyzer = new UpdateQueryAnalyzer(queryAnalyzer);

assertEquals("Account", analyzer.getFromObjectName());

// Verify we have exactly one rec to save
assertEquals(1, analyzer.getRecords(List.of()).size());
Map<String, Object> rec = analyzer.getRecords(List.of()).get(0);
// Verify the fields count for the first rec
assertEquals(3, rec.size());
// Verify the fields' names for the first rec
assertEquals(Set.of("IsDeleted", "Name", "Id"), rec.keySet());
assertEquals("FirstAccount_new", rec.get("Name"));
assertTrue((Boolean) rec.get("IsDeleted"));
assertEquals("001xx000003GeY0AAK", rec.get("Id"));
}
}

0 comments on commit 86bd663

Please sign in to comment.