mtxr / vscode-sqltools

Database management for VSCode
https://vscode-sqltools.mteixeira.dev?utm_source=github&utm_medium=homepage-link
MIT License
1.43k stars 291 forks source link

`//`(Floor Division) on CockroachDB query formatted to `/ /`, breaking the query #1234

Closed jonasbadstuebner closed 8 months ago

jonasbadstuebner commented 8 months ago

Describe the bug When I created a query for CockroachDB like

ALTER TABLE IF EXISTS mytable ADD COLUMN IF NOT EXISTS "special" STRING AS ((duration_seconds // 86400)::STRING) VIRTUAL;

using the floor division of CockroachDB (// -> ref) it get's formatted to

ALTER TABLE IF EXISTS mytable
ADD COLUMN IF NOT EXISTS "special" STRING AS ((duration_seconds / / 86400)::STRING) VIRTUAL;

and the query is invalid now (/ / is not real).

To Reproduce Steps to reproduce the behavior:

  1. Create test.sql with the contents from above
  2. Format the file with vscode-sqltools

Expected behavior The query should be

ALTER TABLE IF EXISTS mytable
ADD COLUMN IF NOT EXISTS "special" STRING AS ((duration_seconds // 86400)::STRING) VIRTUAL;

Desktop (please complete the following information):