Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix handling of multiline SQL in SQLite3 schema #3411
Knex version: 0.19.2
Should you have any question or suggestion don't hesitate to ask, I will make the necessary changes quickly, so that you can merge it as soon as possible.
No, I'm not calling knex.raw, just using a simple migration script as you can see in the attached file:
The multiline SQL is coming from the database file since SQLite3 is storing schema as a create statement in sqlite_master table. The multiline SQL create statement added by the DB Browser tool because my database is a legacy one and have not been created with a migration script from the beginning but by hand. DDL class is finding table schema with the getTableSql method which is returning the multiline SQL.
I kindly ask you to read again my original comment carefully, try out the migration script and the DB attached, run and inspect the failing tests separately commited in 82a46a0
@kibertoad I've added an end to end test.
At the start of the test run for SQLite3 we copy sample.sqlite3 to test.sqlite3 and it contains a test table which has been created with DB Browser for SQLite (this causes the bug because it contains the multiline expression). The new test case has two migration script, one for renaming a column and the other for dropping the column.
I've patched the double quote backward compatibility regex from
I fixed the code related to your comments.
I had to change the identifier replacing logic too, because there were already some logic for backward compatibility related to double quotes and backsticks. I implemented this as a way to replace identifier style to the one which was given as the "to" parameter. The "from" parameter is stripped to get the identifier name without quotes and backsticks and replace it to "to" parameter as it received.