FriendsOfDoctrine / dbal-clickhouse

Doctrine DBAL driver for ClickHouse database
GNU General Public License v3.0
98 stars 80 forks source link

Fix binding values #28

Open marliotto opened 5 years ago

marliotto commented 5 years ago

Hello, I've fixed rewriting values when values was been set through bindValue(). For example:

$statement = $this->connection->prepare('INSERT INTO test_insert_table(id, payload) VALUES (?, ?), (?, ?)');
$statement->bindValue(0, 7, ParameterType::INTEGER);
$statement->bindValue(1, 'v?7');
$statement->bindValue(2, 8, ParameterType::INTEGER);
$statement->bindValue(3, 'v8');

Result SQL:

INSERT INTO test_insert_table(id, payload) VALUES (7, 'v87'), ('v8', ?)

Fixed bug with keys that have the same prefix. For example:

$statement = $this->connection->prepare('INSERT INTO test_insert_table(id, payload) VALUES (:v1, :v10)');
$statement->execute(['v1' => 1, 'v10' => 'v1');

Also, new solution supports keys like '?' and ':key' in one query.

marliotto commented 5 years ago

Hello @mochalygin , @argayash ! Could you check my PR? It will fix https://github.com/FriendsOfDoctrine/dbal-clickhouse/issues/22