-
Notifications
You must be signed in to change notification settings - Fork 890
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
Support Literal values in inserts #2301
Conversation
b274511
to
b0afe3a
Compare
b0afe3a
to
8b69122
Compare
@markstory Do we need to port this to migrations as well? |
if ($value instanceof Literal) { | ||
return (string)$value; | ||
} |
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.
quoteValue
is used only in the insert functions for dry-run output as well as two queries in the sqlite adapter where it always operates on a string, so not much risk this breaks something.
$data = [ | ||
[ | ||
'column1' => 'value1', | ||
'column3' => Literal::from('CURRENT_TIMESTAMP'), |
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.
👍
Port cakephp/phinx#2301 to migrations. Fixes #737
Closes #2297
PR adds support for using
\Phinx\Util\Literal
in insert operations, so that can do stuff like insertCURRENT_TIMESTAMP
. Previously, we were always passing all values in the insert data as binded variables to the escaped SQL statement. Now, the literal values will be inserted directly into the escaped SQL statement, while non literals values will continue to be binded.