Skip to content

adding exportCsv in Query module#5799

Merged
delchev merged 2 commits intomasterfrom
exportCsv-api
Mar 25, 2026
Merged

adding exportCsv in Query module#5799
delchev merged 2 commits intomasterfrom
exportCsv-api

Conversation

@delchev
Copy link
Contributor

@delchev delchev commented Mar 25, 2026

// Export CSV

const sql = "SELECT * FROM DIRIGIBLE_EXTENSIONS WHERE EXTENSION_EXTENSIONPOINT_NAME = :editor";
query.exportCsv(sql, [{ "name": "editor", "type": "VARCHAR", "value": "platform-editors" }], "SystemDB", "my-export-file");

continue;
}

try (Connection connection = dataSource.getConnection()) {

Check notice

Code scanning / CodeQL

Inefficient empty string test Note

Inefficient comparison to empty string, check for zero length instead.

Copilot Autofix

AI about 22 hours ago

In general, to fix this category of issue you should replace s.equals("") or "".equals(s) with either s.isEmpty() (preferred in Java 6+) or s.length() == 0 when s is known to be non-null. In contexts where you must guard against null, keep the guard (s != null && s.isEmpty()).

In this specific case, line is obtained from StringTokenizer.nextToken(), which never returns null, so line.trim() is also guaranteed non-null. Therefore, the most direct and clear fix is to replace "".equals(line.trim()) with line.trim().isEmpty(). This change preserves behavior (skip tokens that are only whitespace) and matches the codebase’s existing pattern of using length-based or isEmpty() emptiness checks. No new imports or helper methods are needed. The only region to change is line 240 in components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/service/DatabaseExecutionService.java.

Suggested changeset 1
components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/service/DatabaseExecutionService.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/service/DatabaseExecutionService.java b/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/service/DatabaseExecutionService.java
--- a/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/service/DatabaseExecutionService.java
+++ b/components/data/data-management/src/main/java/org/eclipse/dirigible/components/data/management/service/DatabaseExecutionService.java
@@ -237,7 +237,7 @@
         StringTokenizer tokenizer = new StringTokenizer(sql, getDelimiter(sql));
         while (tokenizer.hasMoreTokens()) {
             String line = tokenizer.nextToken();
-            if ("".equals(line.trim())) {
+            if (line.trim().isEmpty()) {
                 continue;
             }
 
EOF
@@ -237,7 +237,7 @@
StringTokenizer tokenizer = new StringTokenizer(sql, getDelimiter(sql));
while (tokenizer.hasMoreTokens()) {
String line = tokenizer.nextToken();
if ("".equals(line.trim())) {
if (line.trim().isEmpty()) {
continue;
}

Copilot is powered by AI and may make mistakes. Always verify output.
@delchev delchev merged commit 1c77792 into master Mar 25, 2026
10 of 11 checks passed
@delchev delchev deleted the exportCsv-api branch March 25, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant