Skip to content

Commit 672e154

Browse files
authored
Merge pull request #6871 from kenjis/disable-BaseBuilder-setAlias
feat: disable BaseBuilder::setAlias()
2 parents 1a5c89f + 9705628 commit 672e154

File tree

5 files changed

+5
-16
lines changed

5 files changed

+5
-16
lines changed

system/Database/BaseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
19711971
/**
19721972
* Set table alias for dataset sudo table.
19731973
*/
1974-
public function setAlias(string $alias): BaseBuilder
1974+
private function setAlias(string $alias): BaseBuilder
19751975
{
19761976
if ($alias !== '') {
19771977
$this->db->addTableAlias($alias);

tests/system/Database/Live/UpdateTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ public function testUpdateBatchUpdateFieldsAndAlias()
396396
$this->db->table('user')
397397
->updateFields($updateFields)
398398
->onConstraint(['email', new RawSql("{$esc}db_user{$esc}.{$esc}country{$esc} = {$esc}_update{$esc}.{$esc}country{$esc}")])
399-
->setAlias('_update')
400-
->updateBatch($data);
399+
->setData($data, null, '_update')
400+
->updateBatch();
401401

402402
$result = $this->db->table('user')->get()->getResultArray();
403403

user_guide_src/source/database/query_builder.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,16 +1842,6 @@ Class Reference
18421842

18431843
Used for ``*Batch()`` methods to set data for insert, update, upsert.
18441844

1845-
.. php:method:: setAlias($alias)
1846-
1847-
:param string $alias: Alias for table
1848-
:returns: ``BaseBuilder`` instance (method chaining)
1849-
:rtype: ``BaseBuilder``
1850-
1851-
.. versionadded:: 4.3.0
1852-
1853-
This allows setting an alias for the psuedo table generated with ``setData()``.
1854-
18551845
.. php:method:: setUpdateBatch($key[, $value = ''[, $escape = null]])
18561846
18571847
:param mixed $key: Field name or an array of field/value pairs

user_guide_src/source/database/query_builder/092.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
$builder->setData($data)->onConstraint('title, author')->updateBatch();
2222

2323
// OR
24-
$builder->setData($data)
25-
->setAlias('u')
24+
$builder->setData($data, null, 'u')
2625
->onConstraint(['`mytable`.`title`' => '`u`.`title`', 'author' => new RawSql('`u`.`author`')])
2726
->updateBatch();
2827

user_guide_src/source/database/query_builder/110.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
'country' => 'Afghanistan',
88
];
99

10-
$builder->updateFields('name, country')->setAlias('_upsert')->upsert($data);
10+
$builder->updateFields('name, country')->setData($data, null, '_upsert')->upsert();
1111
/* SQLSRV produces:
1212
MERGE INTO "test"."dbo"."db_user"
1313
USING (

0 commit comments

Comments
 (0)