Skip to content

Conversation

@MasterOdin
Copy link
Member

@MasterOdin MasterOdin commented Aug 4, 2024

Closes #2297

PR adds support for using \Phinx\Util\Literal in insert operations, so that can do stuff like insert CURRENT_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.

@MasterOdin MasterOdin force-pushed the feat-literal-insert branch 6 times, most recently from b274511 to b0afe3a Compare August 4, 2024 18:10
@MasterOdin MasterOdin force-pushed the feat-literal-insert branch from b0afe3a to 8b69122 Compare August 4, 2024 18:17
@MasterOdin MasterOdin marked this pull request as ready for review August 4, 2024 18:21
@dereuromark
Copy link
Member

@markstory Do we need to port this to migrations as well?

Comment on lines +374 to +376
if ($value instanceof Literal) {
return (string)$value;
}
Copy link
Member Author

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.

@MasterOdin MasterOdin merged commit b0f4397 into 0.x Aug 5, 2024
@MasterOdin MasterOdin deleted the feat-literal-insert branch August 5, 2024 14:39
$data = [
[
'column1' => 'value1',
'column3' => Literal::from('CURRENT_TIMESTAMP'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to seed rows using CURRENT_TIMESTAMP

4 participants