hansva commented on code in PR #9361:
URL: https://github.com/apache/hop/pull/9361#discussion_r4537248291
##########
plugins/databases/mssqlnative/src/main/java/org/apache/hop/workflow/actions/mssqlbulkload/ActionMssqlBulkLoad.java:
##########
@@ -286,16 +287,15 @@ public Result execute(Result previousResult, int nr) {
}
// Check Specific Code page
if (codePage.equals("Specific")) {
Review Comment:
This only works in English: the dialog adds the translated
`ActionMssqlBulkLoad.CodePage.Specific` label to the combo (dialog line 471)
and saves `wCodePage.getText()` (line 1121). In a French GUI that stores
`Spécifique`, so `codePage.equals("Specific")` is false and SQL Server gets
`CODEPAGE = 'Spécifique'`. Same for es_AR, it_IT, ja_JP, pt_BR and zh_CN, which
all translate this key. Since the docs no longer warn about it, those users hit
the bug this PR fixes without an explanation.
I think the fix is to store a stable code instead of the label, e.g. an enum
implementing `IEnumHasCodeAndDescription` (code `SPECIFIC`, description from
the bundle), with the existing localized values mapped back when loading.
##########
plugins/databases/mssqlnative/src/main/java/org/apache/hop/workflow/actions/mssqlbulkload/ActionMssqlBulkLoad.java:
##########
@@ -286,16 +287,15 @@ public Result execute(Result previousResult, int nr) {
}
// Check Specific Code page
if (codePage.equals("Specific")) {
- String realCodePage = resolve(codePage);
- if (specificCodePage.length() < 0) {
+ String realCodePage = resolve(specificCodePage);
+ if (Utils.isEmpty(realCodePage)) {
+ result.setNrErrors(1);
logError(
BaseMessages.getString(
PKG,
"ActionMssqlBulkLoad.Error.SpecificCodePageMissing"));
return result;
-
- } else {
- useCodepage = "CODEPAGE = '" + realCodePage + "'";
}
+ useCodepage = "CODEPAGE = '" + realCodePage + "'";
Review Comment:
The resolved *Specific codepage* text now goes into the BULK INSERT
statement as-is. Before, this path could only produce the constant
`'Specific'`. If it's `${CP}` and CP contains a quote (e.g. `65001',
FIRE_TRIGGERS --`), the WITH clause breaks or gets extra options. Could the
value be validated (a number, or ACP/OEM/RAW) before it's put into the SQL?
##########
integration-tests/mssql/0010-bulk-load-options.hwf:
##########
@@ -0,0 +1,518 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+ <name>0010-bulk-load-options</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description>Bulk load options and the checks that stop a load
(#9167).</description>
+ <extended_description/>
+ <workflow_version/>
+ <created_user>-</created_user>
+ <created_date>2026/11/07 12:00:00.000</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/11/07 12:00:00.000</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <DayOfMonth>1</DayOfMonth>
+ <doNotWaitOnFirstExecution>N</doNotWaitOnFirstExecution>
+ <hour>12</hour>
+ <intervalMinutes>60</intervalMinutes>
+ <intervalSeconds>0</intervalSeconds>
+ <minutes>0</minutes>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <weekDay>1</weekDay>
+ <parallel>N</parallel>
+ <xloc>80</xloc>
+ <yloc>80</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Create table</name>
+ <description/>
+ <type>SQL</type>
+ <attributes/>
+ <connection>${MSSQL_CONNECTION}</connection>
+ <sendOneStatement>N</sendOneStatement>
+ <sql>DROP TABLE IF EXISTS master.dbo.[bulk-load-options];
+
Review Comment:
This case passes for any failure, not just the plugin-ID check: if the
PostgreSQL plugin or the `not-mssql` metadata isn't loaded, `dbMeta` is null,
the NPE is caught by the generic catch and errors == 1 still holds. Checking
the log text, or asserting that `dbMeta` isn't null first, would make sure it
tests the new check.
##########
plugins/databases/mssqlnative/src/main/java/org/apache/hop/workflow/actions/mssqlbulkload/ActionMssqlBulkLoad.java:
##########
@@ -249,7 +249,7 @@ public Result execute(Result previousResult, int nr) {
// User has specified a connection, We can continue ...
String pluginId = dbMeta.getPluginId();
if (!("MSSQL".equals(pluginId) || "MSSQLNATIVE".equals(pluginId)))
{
-
+ result.setNrErrors(1);
Review Comment:
Small one: this is one of four new `setNrErrors(1); logError(...); return
result;` sequences, next to the existing ones (about 8 now). A small
`fail(result, message)` helper would make it impossible for a future check to
forget the error count and bring back the 'false with 0 errors' bug.
##########
plugins/databases/mssqlnative/src/main/java/org/apache/hop/workflow/actions/mssqlbulkload/ActionMssqlBulkLoad.java:
##########
@@ -286,16 +287,15 @@ public Result execute(Result previousResult, int nr) {
}
// Check Specific Code page
if (codePage.equals("Specific")) {
- String realCodePage = resolve(codePage);
- if (specificCodePage.length() < 0) {
+ String realCodePage = resolve(specificCodePage);
Review Comment:
An empty *Specific codepage* is only detected here at runtime, after
connecting and checking the table. Could `check()` also report it, so the
workflow Check in the GUI warns about it?
##########
integration-tests/mssql/metadata/rdbms/not-mssql.json:
##########
@@ -0,0 +1,27 @@
+{
+ "virtualPath": "",
+ "rdbms": {
+ "POSTGRESQL": {
+ "databaseName": "none",
+ "pluginId": "POSTGRESQL",
+ "accessType": 0,
+ "hostname": "never-connected",
+ "password": "Encrypted 2be98afa605d39a8da51ee367d180a4c9",
+ "pluginName": "PostgreSQL",
+ "port": "5432",
+ "attributes": {
+ "SUPPORTS_TIMESTAMP_DATA_TYPE": "Y",
+ "QUOTE_ALL_FIELDS": "N",
+ "SUPPORTS_BOOLEAN_DATA_TYPE": "Y",
+ "FORCE_IDENTIFIERS_TO_LOWERCASE": "N",
+ "PRESERVE_RESERVED_WORD_CASE": "Y",
+ "SQL_CONNECT": "",
+ "FORCE_IDENTIFIERS_TO_UPPERCASE": "N",
+ "PREFERRED_SCHEMA_NAME": ""
+ },
+ "manualUrl": "",
+ "username": "no-user"
+ }
+ },
+ "name": "not-mssql"
+}
Review Comment:
Nit: no trailing newline, unlike `mssql-2022.json` and `mssql-2025.json`;
Hop adds it back when the connection is saved, giving a spurious diff.
##########
plugins/databases/mssqlnative/src/main/java/org/apache/hop/workflow/actions/mssqlbulkload/ActionMssqlBulkLoad.java:
##########
@@ -338,7 +339,10 @@ public Result execute(Result previousResult, int nr) {
// End file at
if (endFile > 0) {
- takeFirstNbrLines = "LASTROW=" + endFile;
+ if (!takeFirstNbrLines.isEmpty()) {
Review Comment:
Building the WITH clause (FIRSTROW + LASTROW, the specific codepage) is pure
string work, but it's only covered by the IT that needs two SQL Server
containers. A unit test that captures the generated SQL with a mocked
`Database` would catch regressions in the normal build.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]