mtxr / SublimeText-SQLTools

SQLTools for Sublime Text 3
https://code.mteixeira.dev/SublimeText-SQLTools/
GNU General Public License v3.0
177 stars 40 forks source link

Bug : formatted sql statement is reporting syntax error #101

Closed cooljeffrey closed 7 years ago

cooljeffrey commented 7 years ago

Issue Type

Prerequisites (For bugfixes)

Description

A SQL statement formatted by SQLTools will report syntax error, while it can be executed successfully once joined into one single line ( e.g using CMD+J in SublimeText 3).

SELECT 1 AS ID,
       'A' AS `CODE`,
       'CARRIER' AS Description
UNION
SELECT 2 AS ID,
       'B' AS `CODE`,
       'ADMINISTRATOR' AS Description
UNION
SELECT 3 AS ID,
       'C' AS `CODE`,
       'CLIENT' AS Description
UNION
SELECT 4 AS ID,
       'D' AS `CODE`,
       'REQUEST' AS Description
UNION
SELECT 5 AS ID,
       'E' AS `CODE`,
       'FEE' AS Description
UNION
SELECT 6 AS ID,
       'F' AS `CODE`,
       'SUPPORTED_DELIVERY' AS Description
UNION
SELECT 7 AS ID,
       'G' AS `CODE`,
       'COMMISSION' AS Description
UNION
SELECT 8 AS ID,
       'H' AS `CODE`,
       'CREDIT' AS Description
UNION
SELECT 9 AS ID,
       'I' AS `CODE`,
       'SUPPORTED_PRICING' AS Description
UNION
SELECT 10 AS ID,
       'J' AS `CODE`,
       'LOCATION' AS Description ;

Steps to Reproduce (For bugfixes)

  1. Copy and paste above sql into sublime text 3
  2. Execute ST: explain plan, it shows syntax error at random part of that SQL.
  3. Join the lines into a single line using CMD+J, then ST: explain plan, it return success.

Versions

tkopets commented 7 years ago

Unfortunately, I was unable to reproduce. Note: By default, SQLTools will execute the currently selected text and if the selection is empty only current line under the cursor is sent to DB CLI (mysql). Try selecting the piece of SQL you wish to execute/explain and then run the command.

You may consider using option "expand_to_paragraph": true to execute statements between empty newlines, if selection is empty. Please let me know if that solves your problem.

cooljeffrey commented 7 years ago

@tkopets That is it! Sorry for my misunderstanding of the usage. And thanks for your time.