-
Notifications
You must be signed in to change notification settings - Fork 40
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
Incorrect parse of SQL file with double semicolon #138
Comments
I don't quite understand where the extra semicolons are coming from. I see a single semicolon in Symfony source code |
Could we test & optionally fix this & integrate through https://github.com/nextras/multi-query-parser/? |
Good question. I thought that it is some Postgres specific weirdness in a function definition, but it works with a single semicolon too. ... I have found the reason - it comes from Sylis migration $this->addSql('CREATE OR REPLACE FUNCTION notify_messenger_messages() RETURNS TRIGGER AS $$
BEGIN
PERFORM pg_notify(\'messenger_messages\', NEW.queue_name::text);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;');
$this->addSql('DROP TRIGGER IF EXISTS notify_trigger ON messenger_messages;');
$this->addSql('CREATE TRIGGER notify_trigger AFTER INSERT OR UPDATE ON messenger_messages FOR EACH ROW EXECUTE PROCEDURE notify_messenger_messages();'); and that is doubled by Doctrine itself in $string .= $query->getStatement() . ";\n"; Conclusion
# SELECT 1 AS semicolon_madness;;;
semicolon_madness
-------------------
1
(1 row) |
Note that |
I would say the main issue is that the Sylius migration is just wrong. It should not contain the terminating semicolon.
Double semicolon has no meaning in postgre. I guess we can ignore the empty statement. |
In this part I disagree. Standard semicolon at the end of a query should be simply silently removed by a PHP library, not causing crashes.
Yup, that sounds like a best clean solution 👏 |
Symfony messenger generated following SQL migration for PostgreSQL
\Nextras\Migrations\Drivers\BaseDriver::loadFile
parse it incorrectly considering as a valid delimiter only single;
, which results into empty SQL commandThe text was updated successfully, but these errors were encountered: