Skip to content

Commit 615ed83

Browse files
committed
Fix CS and phpstan
1 parent 32d350c commit 615ed83

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

system/Database/BaseBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class BaseBuilder
163163
*
164164
* @phpstan-var array{
165165
* updateFieldsAdditional?: array,
166+
* tableIdentity?: string,
166167
* updateFields?: array,
167168
* constraints?: array,
168169
* fromQuery?: string,

system/Database/SQLSRV/Builder.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -634,23 +634,16 @@ protected function _upsertBatch(string $table, array $keys, array $values): stri
634634

635635
$constraints = $this->QBOptions['constraints'] ?? [];
636636

637-
$tableIdentity = $this->QBOptions['tableIdentity'] ?? [];
638-
639-
if (empty($tableIdentity)) {
640-
$sql = "SELECT name from syscolumns where id = Object_ID('" . $table . "') and colstat = 1";
641-
642-
if (($query = $this->db->query($sql)) === false) {
643-
throw new DatabaseException('Failed to get table identity'); // @codeCoverageIgnore
644-
}
645-
646-
$query = $query->getResultObject();
647-
648-
foreach ($query as $row) {
649-
$tableIdentity = '"' . $row->name . '"';
650-
}
651-
652-
$this->QBOptions['tableIdentity'] = $tableIdentity;
637+
$tableIdentity = $this->QBOptions['tableIdentity'] ?? '';
638+
$sql = "SELECT name from syscolumns where id = Object_ID('" . $table . "') and colstat = 1";
639+
if (($query = $this->db->query($sql)) === false) {
640+
throw new DatabaseException('Failed to get table identity');
641+
}
642+
$query = $query->getResultObject();
643+
foreach ($query as $row) {
644+
$tableIdentity = '"' . $row->name . '"';
653645
}
646+
$this->QBOptions['tableIdentity'] = $tableIdentity;
654647

655648
$identityInFields = in_array($tableIdentity, $keys, true);
656649

user_guide_src/source/database/query_builder/111.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
];
1717

1818
$additionalUpdateField = ['updated_at' => new RawSql('CURRENT_TIMESTAMP')];
19-
19+
2020
$sql = $builder->setData($data)->updateFields($additionalUpdateField, true)->upsertBatch();
2121
/* MySQLi produces:
2222
INSERT INTO `db_user` (`country`, `email`, `name`)

0 commit comments

Comments
 (0)