jakebathman / mysql-syntax

VS Code syntax support for MySQL
11 stars 5 forks source link

PHP syntax highlight bug with SQL strings with as word #20

Open a-bentofreire opened 6 years ago

a-bentofreire commented 6 years ago

If I activate mysql-syntax extension, the following code will consider the comment below and the echos as strings:

<?php
$sql = 'SELECT users.username as u1, users2.username as u2'
  .' users.username as u3, users2.username as u4';

// echo "sql:$sql\n"; // DEBUG INFO
echo "hello world";
echo "hello world";

However If I remove the as u2, this problem stops from occurring. The code below has no problems:

<?php
$sql = 'SELECT users.username as u1, users2.username'
  .' users.username as u3, users2.username as u4';

// echo "sql:$sql\n"; // DEBUG INFO
echo "hello world";
echo "hello world";

mysql-syntax disabled: with-no-extension

mysql-syntax enabled: with-extension

mysql-syntax enabled but no as u2: without-as

MasterOdin commented 5 years ago

Another example of this that I encountered was:

<?php

$test = "SELECT count(*) FROM (SELECT * FROM table) AS subquery";
print($b);

where the ways I found to fix this was:

  1. Remove the AS subquery bit
  2. Add a space to the end of the string