-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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 BaseBuilder setAlias() and RawSql use with key value pairs #6741
Conversation
Added $this->db->addTableAlias($alias) to setAlias(). This keeps track of the alias and prevents adding the database prefix when using $this->db->protectIdentifiers(). There was some issues with this. Also made some fixes to updateBatch() and use of RawSql. Just a small fix that allows key value pairs with RawSql.
use RawSql with key value pairs on constraints.
The bug can be seen in UpdateTest Before I had to use the database prefix when defining the alias so that protectIdentifiers matched. This is no longer the case. |
@kenjis Can we expedite this fix? |
Make only one change per commit if possible. When fixing a bug, it is recommended that you first write a test case that fails because of the bug. |
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.
I have not looked at the details of the specific DB drivers, but the test code is okay and the test passes.
LGTM.
This would be the difference of the test that I altered. I had hacked the bug in the test and now you see the test as it should be. |
I think one more thing I should add is to throw an exception if you use an alias for upsert with Postgres and SQLite. They are always Identified by "excluded". This way a developer doesn't get lost trying to figure out why their alias is not working. ...DONE |
These are forced by DB to always be referred to as "excluded". A custom alias cannot be set.
If the error is not thrown here it will through one on query execution.
Please fix Exceptions for upsert with Postgres and SQLite.
@sclubricants Thank you! |
This fixes an issue when using an alias with setAlias() method. When using escape identifiers it was adding database prefix to alias. This was fixed.
Also, a small change to use of RawSql in constraints for updateBatch() and upsertBatch(). RawSql can be used for the entire expression or used as a key value pair. This is how I originally intended it but somehow it didn't get in correctly.
Can we expedite merging this? These fixes are needed for my other PRs.
Checklist: