Skip to content

Metadata check warns about working TOP statement  #1776

@Quafadas

Description

@Quafadas

Driver version

ivy"com.microsoft.sqlserver:mssql-jdbc:10.2.0.jre17",

SQL Server version

Provide the output of executing SELECT @@VERSION on your target SQL Server.
Microsoft SQL Server 2019 (RTM-CU15) (KB5008996) - 15.0.4198.2 (X64)
Jan 12 2022 22:30:08
Copyright (C) 2019 Microsoft Corporation
Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) (Hypervisor)

Client Operating System

Windows

JAVA/JVM version

Provide the JAVA/JVM version (e.g. java version "1.8.0").
17.0.2

Table schema

Provide the table schema to repro the issue.
None needed;

val limit = 1
sql" SELECT TOP ( $limit ) val FROM (values (3),(5)) as t(val) ".query[Int]

Problem description

Provide full details of the problem.
This is the complete downstream manifestation.
typelevel/doobie#1672

When checking the meta data of a valid query, that has a variable "TOP" parameter, the driver errors.

the jdbc java.sql.ParameterMetaData given by the jdbc driver - that's what the driver is returning incorrectly

Expected behavior

The parameter checking should allow a valid (variable) parameter in a TOP statement.

Actual behavior

The query runs successfully , but fails the "metadata test" of the library. The library use (apparently) the java.sql.ParameterMetaData from the driver for that validation.

Query0[scala.Int] defined at DBTest.scala:33
SELECT TOP ( ? ) val FROM (values (3),(5)) as t(val)
? SQL Compiles and TypeChecks
The number of rows provided for a TOP or FETCH clauses row count
parameter must be an integer.

Error message/stack trace

Complete error message and stack trace.

Any other details that can be helpful

JDBC trace logs

Provide the JDBC driver trace logs. Instructions can be found here: https://docs.microsoft.com/sql/connect/jdbc/tracing-driver-operation

Metadata

Metadata

Assignees

Labels

BugA bug in the driver. A high priority item that one can expect to be addressed quickly.

Type

No type

Projects

Status

Closed Issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions