Skip to content

Commit

Permalink
Dev: Include pkey query in postgres debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanJard committed Nov 8, 2024
1 parent c0edd6d commit 6849359
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Database/Driver/PostgresQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ protected function _prepare($sql)
$table = explode(' as ', $this->_table[0]);

// Get the pkey field name
$pkRes = $resource->prepare(
'SELECT a.attname
$pkSql = 'SELECT a.attname
FROM pg_index i
JOIN pg_attribute a ON a.attrelid = i.indrelid
AND a.attnum = ANY(i.indkey)
AND a.attnum = ANY(i.indkey)
WHERE i.indrelid = (:tableName)::regclass
AND i.indisprimary'
);
AND i.indisprimary';

$this->database()->debugInfo($pkSql, ['tableName' => $table[0]]);

$pkRes = $resource->prepare($pkSql);
$pkRes->bindValue('tableName', $table[0]);
$pkRes->execute();
$row = $pkRes->fetch();
Expand Down

0 comments on commit 6849359

Please sign in to comment.