0

Some basics... I have MySQL installed using the latest version of WAMP and it works fine. MySQL v5.7.31 I use the latest version of VSCode, v1.56.2 I Installed the SQLTools Extension for VSCode, v0.23.0 by Matheus Teixeira I installed the SQLTools MySQL/MariaDB Driver for SQLTools, v0.2.0

I started watching a tutorial, https://youtu.be/Cz3WcZLRaWc which helped me install SQLTools. It worked at first but as I progressed I got the above error.

"Cannot destructure property 'name' of 'undefined' as it is undefined"

Sometimes the query still works, like with INSERT INTO, but not with SELECT FROM.

On GIT this was reported back on 10/28/2020 and has not been resolved there.

I see a lot of articles here about that error in reference to Javascript. I don't know if SQLTools uses Javascript or not.

Below is some code.

-- @BLOCK
SELECT * FROM Users; 
-- CREATE TABLE Users(
--     id INT PRIMARY KEY AUTO_INCREMENT,
--     email VARCHAR(255) NOT NULL UNIQUE,
--     bio TEXT,
--     country VARCHAR(2CREATE TABLE Users(
--         id INT PRIMARY KEY AUTO_INCREMENT,
--         email VARCHAR(255) NOT NULL UNIQUE,
--         bio TEXT,
--         country VARCHAR(2)
--     );)
-- );
Lord Dewi
  • 23
  • 6

2 Answers2

1

In my situation I found that it has to do with the commenting. I don't know if this is the case for everyone obviously. I just assume that if code is commented out it's passed over but SQLTools does not seem to see it that way.

What I found was, in my situation, it only comments it out if the new code if AFTER the commented out code. When I put the new code before the commented out code it failed with the indicated error.

What I was doing was commenting out the previous tests, to save them so I could go back and look at them later. Then I would put the new code ABOVE the commented text, assuming it would ignore everything that was commented out.

Apparently NOT. When I moved the NEW code underneath the commented out code it worked without the error some are experiencing. See my code above.

Interestingly, because I was so familiar with using PHP and MySQL and using PHPMyAdmin to check things I found that even with some of those errors, like the INSERT INTO, it still did do the INSERT, even with the error. (I checked PHPMyAdmin).

So this might help some of you, although it is still a bug, all comments should be ignored. Most of you just post the code that is failing but not your full code do I don't know if you have comments before your code.

If I put the SELECT * right under the -- @block it fails.

I hope this helps some of you.

-- @BLOCK
-- CREATE TABLE Users(
--     id INT PRIMARY KEY AUTO_INCREMENT,
--     email VARCHAR(255) NOT NULL UNIQUE,
--     bio TEXT,
--     country VARCHAR(2CREATE TABLE Users(
--         id INT PRIMARY KEY AUTO_INCREMENT,
--         email VARCHAR(255) NOT NULL UNIQUE,
--         bio TEXT,
--         country VARCHAR(2)
--     );)
-- );
SELECT * FROM Users;

Correct Code

Lord Dewi
  • 23
  • 6
1

Try running code after the comments:-

Correct way:-

--Comment1 SQl
--Comment2 SQL
ALTER TABLE <table_name> MODIFY <column_name> INT;

Wrong-way:-

--Comment1 SQl
ALTER TABLE <table_name> MODIFY <column_name> INT;
--Comment2 SQL
Nimantha
  • 6,405
  • 6
  • 28
  • 69