dbcli / mssql-cli

A command-line client for SQL Server with auto-completion and syntax highlighting
BSD 3-Clause "New" or "Revised" License
1.35k stars 192 forks source link

ODBC style date literals cause parser failure #443

Open aberezin opened 4 years ago

aberezin commented 4 years ago

The following fails mssql-cli -S somehost -U someuser -Q 'select {d '2050-01-01'}'

However, the SQL statement runs in, for example, DataGrip connected to the same sqlserver using a jdbcdriver. The sqlserver2019 docs indicate it is a valid date literal (described as ODBC API Specific) https://docs.microsoft.com/en-us/sql/t-sql/data-types/date-transact-sql?view=sql-server-ver15

Simple workaround is not use that syntax for date literals.

| Microsoft SQL Server 2016 (SP2-CU10) (KB4524334) - 13.0.5492.2 (X64) | | Oct 4 2019 19:14:08 | | Copyright (c) Microsoft Corporation | | Standard Edition (64-bit) on Windows Server 2016 Datacenter 10.0 (Build 14393: ) (Hypervisor)

ellbosch commented 4 years ago

Thanks @aberezin, I've repro'd this bug on my end. It looks like the bug only shows up in non-interactive mode (using the -Q arg), however if you spin up mssql-cli in interactive mode we're able to parse the date correctly. I'll look to fixing this soon.