Driver version
7.0.0
SQL Server version
Microsoft SQL Server 2017 (RTM-CU10) (KB4342123) - 14.0.3037.1 (X64)
Jul 27 2018 09:40:27
Copyright (C) 2017 Microsoft Corporation
Express Edition (64-bit) on Linux (Ubuntu 16.04.5 LTS)
Client Operating System
Fedora 28
JAVA/JVM version
openjdk version "1.8.0_181"
Table schema
No schema is necessary.
Problem description
Incorrect syntax error is thrown when getting the metadata.
- Expected behaviour: query should work
- Actual behaviour: exception is thrown.
- Error message/stack trace:
A processing error "Incorrect syntax near '?'." occurred.
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:226)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.buildExecuteMetaData(SQLServerPreparedStatement.java:1089)
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.getMetaData(SQLServerPreparedStatement.java:1058)
...
- Any other details that can be helpful: see miinimized test case
JDBC trace logs
don't think they're necessary.
Reproduction code
Minimized test case of the function com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.replaceMarkerWithNull:
package com.microsoft.sqlserver.jdbc;
import static com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.replaceMarkerWithNull;
public class Something {
public static void main(String[] args) {
String x = "select (case when 1 = ? then 1 else 0 end) as [a '], (case when 1 = ? then 1 else 0 end) as [b ']";
System.out.println(replaceMarkerWithNull(x));
}
}
output:
select (case when 1 = null then 1 else 0 end) as [a '], (case when 1 = ? then 1 else 0 end) as [b ']
expected (I assume):
select (case when 1 = null then 1 else 0 end) as [a '], (case when 1 = null then 1 else 0 end) as [b ']
When we change the query to:
select (case when 1 = ? then 1 else 0 end) as [a ?], (case when 1 = ? then 1 else 0 end) as [b ']
we get
select (case when 1 = null then 1 else 0 end) as [a null], (case when 1 = null then 1 else 0 end) as [b ']
which I guess is also wrong since it will give a different column name in the metadata.
Driver version
7.0.0
SQL Server version
Microsoft SQL Server 2017 (RTM-CU10) (KB4342123) - 14.0.3037.1 (X64)
Jul 27 2018 09:40:27
Copyright (C) 2017 Microsoft Corporation
Express Edition (64-bit) on Linux (Ubuntu 16.04.5 LTS)
Client Operating System
Fedora 28
JAVA/JVM version
openjdk version "1.8.0_181"
Table schema
No schema is necessary.
Problem description
Incorrect syntax error is thrown when getting the metadata.
JDBC trace logs
don't think they're necessary.
Reproduction code
Minimized test case of the function
com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.replaceMarkerWithNull:output:
expected (I assume):
When we change the query to:
we get
which I guess is also wrong since it will give a different column name in the metadata.