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
Fix for createViewOrReplace and its support for sqlite3 #4856
Fix for createViewOrReplace and its support for sqlite3 #4856
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the report + PR ! Tests fails
@kibertoad maybe could be nice to add this in 0.95.15 ? |
sure, sounds good |
@kibertoad I push returns, if you can take a look. |
@OlivierCavadenti sorry, I was busy and then sick. Have you sorted it out? BTW I was thinking whether the functionality could behave the same as in sqlite3 across all dbs. In postgres, when you use the builtin functionality, it needs to have the same columns in same order and new ones at the end. I ended up using drop and create anyway. await Model.knex().schema.dropViewIfExists(dBViewName);
dbView = await Model.knex().schema.createView(
dBViewName,
(view) => {
view.as(Model.knex().raw(query));
}
); |
No problem ^^.
I am afraid I dont understand, you need to create new view but with same columns in same order when you use createViewOrReplace ? I dont test that, but it throws an error ? EDIT : I see the documentation (it seems good pratice :D) and I see the problem:
|
By the way, I assume this limitation in PostgreSQL (need replace with same columns, same order) it's to dont break all existing queries that query the view you replace. In my opinion, it's better to dont change existing queries 'create or replace view' and so have this safe behavior, and put in Knex documentation what you are saying : the difference between sqlite3 and other dbs. @kibertoad what do think about that ? |
@OlivierCavadenti I agree, handling it via documentation is a better path. |
@kibertoad we will put this one on 1.0.0 (with backport in 0.95.X) or we will merge it after the 1.0.0 tag ? |
@OlivierCavadenti I'm OK with merging it in 1.0.0 if you prefer it that way. |
@OlivierCavadenti Any last minute changes, or I can start releasing 1.0.0 in an hour or so? |
I dont see anything else. I will track carefully any issues if anything need to be fix before/after the 1.0.0 tag :D. |
Released in 1.0.1 |
Related issues:
Closes #4854
Closes #4855