Skip to content

Commit

Permalink
bug: Column was not escaped for clause REPLACE ROW DELETION POLICY (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
taka-oyama authored Aug 1, 2023
1 parent 8efa875 commit 5c89cc6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Changed

Fixed
- Transaction state was not being cleared if rolled back failed. (#107)
- Column was not escaped for clause `REPLACE ROW DELETION POLICY` (#125)

# v5.1.0

Expand Down
4 changes: 3 additions & 1 deletion src/Schema/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ public function compileReplaceRowDeletionPolicy(Blueprint $blueprint, Fluent $co
if ($command->policy !== 'olderThan') {
throw new RuntimeException('Unknown deletion policy:'.$command->policy);
}
return "alter table {$this->wrapTable($blueprint)} replace row deletion policy (older_than({$command->column}, interval {$command->days} day))";
$table = $this->wrapTable($blueprint);
$column = $this->wrap($command->column);
return "alter table {$table} replace row deletion policy (older_than({$column}, interval {$command->days} day))";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Schema/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ public function test_replace_row_deletion_policy(): void
$statement = $blueprint2->toSql($conn, $grammar)[0];

self::assertEquals(
"alter table `{$table}` replace row deletion policy (older_than(t, interval 200 day))",
"alter table `{$table}` replace row deletion policy (older_than(`t`, interval 200 day))",
$statement,
);
}
Expand Down

0 comments on commit 5c89cc6

Please sign in to comment.