-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL integration test fail in section testNamedParameters #214
Comments
Could you check if:
This seems like MySQL telling us that |
I did it for PHP 7.4 CLI and have the same result.
# Went to clone of "laminas-db" and check "is all ok?"
$ git remote -v
# origin https://github.com/laminas/laminas-db.git (fetch)
# origin https://github.com/laminas/laminas-db.git (push)
$ git branch -a
# 2.12.x
# * 2.13.x
# 2.14.x
# remotes/origin/2.11.x
# remotes/origin/2.12.x
# remotes/origin/2.13.x
# remotes/origin/2.13.x-merge-up-into-2.14.x_3Y5r1t4x
# remotes/origin/2.13.x-merge-up-into-2.14.x_LxxfGKFv
# remotes/origin/2.14.x
# remotes/origin/HEAD -> origin/2.13.x
# remotes/origin/dev-3.0.0
# remotes/origin/dev-3.0.0-old
# remotes/origin/gh-pages
# Update vendor libraies
$ docker run --rm -it --volume $(pwd):/app zvanoz/laminas-db-test-by-docker:74 composer update
# Loading composer repositories with package information
# Updating dependencies
# Lock file operations: 0 installs, 4 updates, 1 removal
# - Removing laminas/laminas-zendframework-bridge (1.4.0)
# - Upgrading laminas/laminas-servicemanager (3.7.0 => 3.10.0)
# - Upgrading nikic/php-parser (v4.12.0 => v4.13.0)
# - Upgrading phpdocumentor/type-resolver (1.4.0 => 1.5.0)
# - Upgrading phpunit/php-code-coverage (9.2.6 => 9.2.7)
# Writing lock file
# Installing dependencies from lock file (including require-dev)
# Package operations: 46 installs, 0 updates, 0 removals
# ...
# Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
# Generating autoload files
# 33 packages you are using are looking for funding.
# Use the `composer fund` command to find out more!
# PHP CodeSniffer Config installed_paths set to ../../laminas/laminas-coding-standard/src,../../slevomat/coding-standard,../../webimpress,../../webimpress/coding-standard/src
$ git status
# На ветке 2.13.x
# Ваша ветка обновлена в соответствии с «origin/2.13.x».
#
# Изменения, которые не в индексе для коммита:
# (используйте «git add <файл>…», чтобы добавить файл в индекс)
# (используйте «git checkout -- <файл>…», чтобы отменить изменения
# в рабочем каталоге)
#
# изменено: composer.lock
$ docker run --rm -it --volume $(pwd):/app zvanoz/laminas-db-test-by-docker:74 composer -vvv test-integration Result
I will do it after make test docker for PHP 8.0 |
To be clear, if we pass in Just making sure it is just a mistake in |
I did it and the error disappeared PHP 7.4 // test/integration/Adapter/Driver/Pdo/Mysql/QueryTest.php
public function testNamedParameters()
{
$sql = new Sql($this->adapter);
$insert = $sql->update('test');
$insert->set([
'name' => ':name',
'value' => ':value',
])->where(['id' => ':id']);
$stmt = $sql->prepareStatementForSqlObject($insert);
//positional parameters
$stmt->execute([
1,
'foo',
123 // prev value is: 'bar',
]);
//"mapped" named parameters
$stmt->execute([
'c_0' => 1,
'c_1' => 'foo',
'where1' => 123//prev value is: 'bar',
]);
|
Ok, so it's just a faulty test then :-)
I guess this test is totally foobar'd anyway :-\ |
I'm glad I helped figure it out. |
I think I figured out the reason for the error and how to fix it. Let's say we have the following request UPDATE `test` SET `name` = :c_0, `value` = :c_1 WHERE ` id` = :where1
-- binding order
-- Index Bind Name Field name Field type
-- 0 ":c_0" "name" varchar(255)
-- 1 ":c_1" "value" varchar(255)
-- 2 ":where1" "id" int We can call it in two ways.
// positional parameters
$ stmt-> execute ([
1, // Error -- 0 ":c_0" "name" varchar(255)
'foo', // Ok. -- 1 ":c_1" "value" varchar(255)
'bar', // Error -- 2 ":where1" "id" int
]);
//"mapped" named parameters
$ stmt-> execute ([
'c_0' => 1, //Error. -- 0 ":c_0" "name" varchar(255)
'c_1' => 'foo', //Ok. -- 1 ":c_1" "value" varchar(255)
'where1' => 'bar', // Error -- 2 ":where1" "id" int
]); PS: 2021-09-24 |
…rameters"/change failure test to any exception (because github-ci messages different of local messages)
…rameters"/change code style by phpcs and "laminas/laminas-coding-standard"
…rameters"/delete commited "phpcs.xml" (i'm sorry)
…rameters"/fix test "testBindParamByFieldNameIsFail" - wrong name of a fieldName
…tNamedParameters"/fix test "testBindParamByFieldNameIsFail" - wrong name of a fieldName" This reverts commit 808c64a
…rameters"/fix test "testBindParamByFieldNameIsFail" - wrong name of a fieldName
…rameters"/All in root of the project is ignore Signed-off-by: ZVanoZ <[email protected]>
…tNamedParameters"/fix test "testBindParamByFieldNameIsFail" - wrong name of a fieldName" This reverts commit 808c64a
…rameters Signed-off-by: ZVanoZ <[email protected]>
…rameters Signed-off-by: ZVanoZ <[email protected]>
Bug Report
Note, PHP 7.4 in custom Docker image.
Summary
Bound parameters by index is invalid.
Current behavior
When we run tests, laminas-db generate SQL
with params
and we have an error
I think, it happend becouse value ["where1" => bar] bonded with
id
= :where1id has type int.
How to reproduce
Edit "phpunit.xml" and set TESTS_LAMINAS_DB_ADAPTER_DRIVER_MYSQL in state true
Other adapters set state false.
Expected behavior
All tests is success.
The text was updated successfully, but these errors were encountered: