-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8451 from kenjis/fix-postgre-deleteBatch
fix: [Postgre] QueryBuilder::deleteBatch() does not work
- Loading branch information
Showing
2 changed files
with
62 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,52 @@ public function testDeleteBatch(): void | |
$this->dontSeeInDatabase('user', ['email' => '[email protected]', 'name' => 'Ahmadinejad']); | ||
} | ||
|
||
public function testDeleteBatchConstraintsDate(): void | ||
{ | ||
$table = 'type_test'; | ||
|
||
// Prepares test data. | ||
$builder = $this->db->table($table); | ||
$builder->truncate(); | ||
|
||
for ($i = 1; $i < 4; $i++) { | ||
$builder->insert([ | ||
'type_varchar' => 'test' . $i, | ||
'type_char' => 'char', | ||
'type_text' => 'text', | ||
'type_smallint' => 32767, | ||
'type_integer' => 2_147_483_647, | ||
'type_bigint' => 9_223_372_036_854_775_807, | ||
'type_float' => 10.1, | ||
'type_numeric' => 123.23, | ||
'type_date' => '2023-12-0' . $i, | ||
'type_datetime' => '2023-12-21 12:00:00', | ||
]); | ||
} | ||
|
||
$data = [ | ||
['date' => '2023-12-01', 'unused' => 'You can have fields you dont use'], | ||
['date' => '2023-12-02', 'unused' => 'You can have fields you dont use'], | ||
]; | ||
$builder = $this->db->table($table) | ||
->setData($data, null, 'data') | ||
->onConstraint(['type_date' => 'date']); | ||
$builder->deleteBatch(); | ||
|
||
$this->dontSeeInDatabase( | ||
$table, | ||
['type_date' => '2023-12-01', 'type_varchar' => 'test1'] | ||
); | ||
$this->dontSeeInDatabase( | ||
$table, | ||
['type_date' => '2023-12-02', 'type_varchar' => 'test2'] | ||
); | ||
$this->seeInDatabase( | ||
$table, | ||
['type_date' => '2023-12-03', 'type_varchar' => 'test3'] | ||
); | ||
} | ||
|
||
public function testDeleteBatchWithQuery(): void | ||
{ | ||
$this->forge = Database::forge($this->DBGroup); | ||
|