Skip to content

Commit

Permalink
[fix] generate() quote error with non-string value #1108
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelaon committed Jan 22, 2024
1 parent 1a892c7 commit b409028
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Medoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ protected function generate(string $statement, array $map): string

foreach ($map as $key => $value) {
if ($value[1] === PDO::PARAM_STR) {
$replace = $this->quote($value[0]);
$replace = $this->quote("{$value[0]}");
} elseif ($value[1] === PDO::PARAM_NULL) {
$replace = 'NULL';
} elseif ($value[1] === PDO::PARAM_LOB) {
Expand Down
7 changes: 5 additions & 2 deletions tests/UpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function testUpdate($type)

$this->database->update("account", [
"type" => "user",
"money" => 23.2,
"age[+]" => 1,
"level[-]" => 5,
"score[*]" => 2,
Expand All @@ -37,27 +38,29 @@ public function testUpdate($type)
'default' => <<<EOD
UPDATE "account"
SET "type" = 'user',
"money" = '23.2',
"age" = "age" + 1,
"level" = "level" - 5,
"score" = "score" * 2,
"lang" = 'a:2:{i:0;s:2:"en";i:1;s:2:"fr";}',
"lang" = '["en","fr"]',
"is_locked" = 1,
"uuid" = UUID(),
"object" = :MeD4_mK
"object" = :MeD5_mK
WHERE "user_id" < 1000
EOD,
'mysql' => <<<EOD
UPDATE "account"
SET "type" = 'user',
"money" = '23.2',
"age" = "age" + 1,
"level" = "level" - 5,
"score" = "score" * 2,
"lang" = 'a:2:{i:0;s:2:\"en\";i:1;s:2:\"fr\";}',
"lang" = '[\"en\",\"fr\"]',
"is_locked" = 1,
"uuid" = UUID(),
"object" = :MeD4_mK
"object" = :MeD5_mK
WHERE "user_id" < 1000
EOD,
], $this->database->queryString);
Expand Down

0 comments on commit b409028

Please sign in to comment.