Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when creating trigger #1172

Open
1 of 5 tasks
DanielBailey-web opened this issue Jun 22, 2023 · 5 comments
Open
1 of 5 tasks

Error when creating trigger #1172

DanielBailey-web opened this issue Jun 22, 2023 · 5 comments
Labels

Comments

@DanielBailey-web
Copy link

Describe the bug
I get the following error when running the code below:

CREATE TRIGGER `before_emails_update` BEFORE UPDATE ON `emails` FOR' at line 1

To Reproduce
I assume the problem would work with any trigger that you try to create.

Expected behavior
Trigger should be created

Code

DROP TRIGGER IF EXISTS `before_emails_update`;
DELIMITER $$
CREATE TRIGGER `before_emails_update` BEFORE UPDATE ON `emails` FOR EACH ROW
BEGIN
    IF (NEW.viewCount = -1) THEN
        SET NEW.viewCount = OLD.viewCount + 1;
        SET NEW.lastViewed = NOW();
        if (OLD.viewCount = 0) THEN
            SET NEW.firstViewed = NOW();
        END IF;
    END IF;
END$$
DELIMITER ;

Desktop (please complete the following information):

  • SQLTools Version [0.6]
  • VS Code Version: [latest]
  • OS: [Mac M1]
  • Driver:
    • PostgreSQL/Redshift
    • MySQL/MariaDB
    • MSSQL/Azure
    • SQLite
    • Other? Which...
  • Database version: [MySQL v5.6]
@gjsjohnmurray
Copy link
Collaborator

@DanielBailey-web the 0.6.0 version of the MySQL driver which it looks like you're using was published only yesterday. Have you previously been able to run this kind of SQL code against your MySQL database using an earlier version of the driver? Or are you using SQLTools this way for the first time?

A potential way to determine if the problem is specific to 0.6.0 is to use the gearwheel menu alongside the MySQL driver extension in VS Code's Extensions view, then choose "Install Another Version...", then pick 0.5.1. You'll be prompted to reload VS Code. Then you can test the same statements to see if it's an old problem or a new one.

@DanielBailey-web
Copy link
Author

DanielBailey-web commented Jun 23, 2023

I had tried previously and it did not work with 0.5.1. I had commented on the PR #1140 (albeit on a different GitHub account @VulcanTech-io) for 0.5.2 asking if that would fix it. But no one got back to me on it 😬

@viccie30
Copy link

The same issue also exists for SQLite, which uses the same/similar syntax for trigger definitions: https://www.sqlite.org/lang_createtrigger.html. Every trigger definition contains embedded semicolons.

Another SQL related project ran into the same issues some years ago, if I understand this issue and the related PR correctly.

@DanielBailey-web
Copy link
Author

@gjsjohnmurray is there any movement on this? This is quite literally a feature I would use daily.

@gjsjohnmurray
Copy link
Collaborator

@DanielBailey-web I am not aware of anyone actively working on this at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants