mtxr/vscode-sqltools

MySQL/MariaDB Error: Cannot destructure property 'name' of 'undefined' as it is undefined #723

incansvl posted onGitHub

OS: Windows 10 Pro 64 bit MariaDB: 10.3.12 VSCode: 1.50.1 SQLTools: 0.23.0 SQLTools MySQL/MariaDB: 0.2.0

Description A ~250 line (with comments) SQL script was working correctly in both the MySQL console (mysql command) and in SQLTools (SQLT).

I then added a simple "print status" type command in the script, of the form-

SELECT CONCAT(
    'Output written to: ', @OutputDirectory, @FileName
)  AS  '';

Originally I had a syntax error, so the script was failing in both environments, but having fixed the error, the script runs ok in the console but continues to fail when run from VSCode with the error:

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

Note: If I try to copy+paste the text of the console error into this bug report the result is: [object Object] not sure if that is significant?

To Reproduce (see attachment)

Expected behavior Script runs and writes the text to the console:

+-------------------------------------------------------------------------------------+
|                                                                                     |
+-------------------------------------------------------------------------------------+
| Output written to: C:/Windows/Temp/der2_cciRefset_RefsetDescriptorDelta_GB_20201024 |
+-------------------------------------------------------------------------------------+

VSTools test case.sql.txt


I second this error. The code I'm running on MySQL 8.0 is just three simple UPDATE statements:

UPDATE Employees SET RoleID = 1 WHERE Role = 'administrator';
UPDATE Employees SET RoleID = 2 WHERE Role = 'receptionist';
UPDATE Employees SET RoleID = 3 WHERE Role = 'staff';

Edit: This is now happening every other query for me. Just a lot of javascript errors and having to keep restarting the window

posted by OzzyTheGiant over 4 years ago

I'm getting this error all the time now. I'll have to switch over to mySQL workbench in the mean time. Running MariaDB 10.3.25. Latest VSCode version: 1.51.1. SQLTools version: 0.23.0.

DROP TABLE IF EXISTS Users; CREATE TABLE Users ( id INT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(12) NOT NULL, userpass VARCHAR(12) NOT NULL, email VARCHAR(50) NOT NULL, active BOOLEAN NOT NULL DEFAULT FALSE );

posted by NullsByte over 4 years ago

Executing SQL results into this error! Opening records from explorer works fine.

posted by SKJoy over 4 years ago

Same error here. But this error only occured when using create or drop statements, not for select. (I haven't tested it with other statements) EDIT: Now also sometimes appears for select

posted by rafaelurben about 4 years ago

Any updates regarding this error?

posted by designermonkey about 4 years ago

Something that I just discovered...SQLTools does not seem to like Commenting. I've been watching this tutorial which introduced me to SQLTools and it works fine in the tutorial but did not for me. https://www.youtube.com/watch?v=Cz3WcZLRaWc What I was doing however 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 with out the error we are all experiencing. See my code below.

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.

UPDATE: (A Few minutes later) - I used the code block but it didn't appear as code so attached is a pic of my code. vscodesqltools

-- @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; -- INSERT INTO Users (email, bio, country) -- VALUES -- ('hellow2@world.com', 'foo', 'MX'), -- ('dewi1@lorddewi.com', 'Dewi', 'US'), -- ('david1@daviddevaneyjr.com', 'David', 'US'); SELECT * FROM Users;

posted by LordDewi almost 4 years ago

Yeah, that could really be the problem - I remember also using comments when the issue occurred.

@LordDewi This is not directly related to this topic, but the reason your code block didn't work is that you only used one backtick (`), which corresponds to an inline code block. For multiline code blocks, you should use three backticks (```). You can find more information here. ;)

posted by rafaelurben almost 4 years ago

I ran into this same issue when trying to change the schema of a table with ALTER TABLE.

SET FOREIGN_KEY_CHECKS = 0;

ALTER TABLE person
MODIFY person_id SMALLINT UNSIGNED AUTO_INCREMENT;

SET FOREIGN_KEY_CHECKS = 1

I ended up just running these commands in the Workbench and switch back to SQLTools afterwards. As of yet, I haven't run into any other instances of this issue.

To Reproduce

Follow pages 17 to 34 from Learning SQL.

posted by grantwforsythe almost 4 years ago

This error occurred to me when I try to execute CREATE TABLE statements. The interesting part is, that table was CREATED. So SQL executed successfully. I think it's a problem with display of results.

posted by zdravkoggeorgiev over 3 years ago

I tried to run multiple INSERT queries and got the same error.

posted by nvmker over 3 years ago

Really enjoy SQL tools in vs-code. Just running basic select statements with 1 join and a where/ group by and the only way not to get the error: Cannot destructor property 'name' of 'undefined' as it is undefined Is to take the comments out. Not to bad on small queries but with my longer complex queries and procedures I have to comment through out the script. Going to send a small donation and prayer this gets resolved cause I love the platform and the extension.

posted by michaelweissDM over 3 years ago

@michaelweissdm has funded $10.00 to this issue.


posted by issuehunt-app[bot] over 3 years ago

I'm seeing the same in any insert query, they are indeed successful, initially I though something was wrong with the queries, but I guess its with the output of the result.

posted by mike-pt over 3 years ago

Getting the same thing with literally just the SQL below, no comments.

USE testdb; SHOW TABLES;

Strangely, SHOW DATABASES; works fine though.

posted by SiJiL82 over 3 years ago

Same issues here. Flatpak VSCode on Ubuntu 21.10.

All of my queries worked fine until I ran an INSERT; with other blocks commented out. After that, even queries that worked before are throwing the Cannot destructure property 'name' error.

posted by rconjoe over 3 years ago

This is still an issue, seems like it cannot run anything other than a single statement.

I had something like the following:

USE db; SELECT ...;

If I remove the USE statement, the query runs fine, otherwise I get the 'cannot destructure ...' error.

posted by FrankCoder almost 3 years ago

Fix has been merged.

posted by gjsjohnmurray over 2 years ago

Fund this Issue

$10.00
Rewarded

Rewarded pull request

Recent activities

gjsjohnmurray was rewarded by mtxr for mtxr/vscode-sqltools# 723
over 2 years ago
gjsjohnmurray submitted an output to  mtxr/ vscode-sqltools# 723
over 2 years ago