Skip to content

Commit

Permalink
Ensure PostgresAdapter::useIdentity is always initialized (#2223)
Browse files Browse the repository at this point in the history
  • Loading branch information
othercorey authored Sep 20, 2023
1 parent a1c4ec5 commit acda135
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Phinx/Db/Adapter/PostgresAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ class PostgresAdapter extends PdoAdapter
*/
protected bool $useIdentity;

/**
* {@inheritDoc}
*/
public function setConnection(PDO $connection): AdapterInterface
{
// always set here since connect() isn't always called
$this->useIdentity = (float)$connection->getAttribute(PDO::ATTR_SERVER_VERSION) >= 10;

return parent::setConnection($connection);
}

/**
* {@inheritDoc}
*
Expand Down Expand Up @@ -115,8 +126,6 @@ public function connect(): void
);
}

$this->useIdentity = (float)$db->getAttribute(PDO::ATTR_SERVER_VERSION) >= 10;

$this->setConnection($db);
}
}
Expand Down

0 comments on commit acda135

Please sign in to comment.