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

Invalid alter table SQL generated for SQLite #5572

Closed
simonworkhouse opened this issue Aug 8, 2022 · 4 comments · Fixed by #5577
Closed

Invalid alter table SQL generated for SQLite #5572

simonworkhouse opened this issue Aug 8, 2022 · 4 comments · Fixed by #5577

Comments

@simonworkhouse
Copy link

Bug Report

Q A
Version 3.4.0

Summary

Invalid alter table SQL is generated for SQLite when an unnamed foreign key constraint exists.

Current behaviour

SQLSTATE[HY000]: General error: 1 near "0": syntax error (SQL: CREATE TABLE orders (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, user_id INTEGER DEFAULT NULL, reference VARCHAR(255) DEFAULT NULL COLLATE BINARY, CONSTRAINT 0 FOREIGN KEY (user_id) REFERENCES users (id) ON UPDATE NO ACTION ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE))

How to reproduce

Here's an example of the issue in a Laravel project https://github.com/workhouse-advertising/laravel-sqlite-bug

Expected behaviour

Either the CONSTRAINT 0 portion needs to be omitted or perhaps the key name needs to be quoted like so CONSTRAINT '0', whichever is valid.

@louis-l
Copy link

louis-l commented Aug 8, 2022

Having the same issue, downgrade to v3.3.8 works.

@morozov
Copy link
Member

morozov commented Aug 9, 2022

It looks like the same issue as reported in #4243.

@da-mask
Copy link

da-mask commented Aug 9, 2022

This blew up every one of my PHPUnit tests in my Laravel app, all errored with ErrorException: Undefined array key -1. Downgrading to v3.3.8 resolved it. Probably not much useful info here, but its all I've got.

@github-actions
Copy link

github-actions bot commented Sep 9, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants