diff --git a/CHANGELOG.md b/CHANGELOG.md index 47d810a74..e4801b87b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - Enh #786: Refactor `AbstractSchema::getDataType()` (@Tigrov) - Enh #784: Specify result type of `ConstraintSchemaInterface::getTableIndexes()` method to `IndexConstraint[]` (@vjik) - Enh #784: Remove unused code in `AbstractSchema::getTableIndexes()` (@vjik) +- Bug #788: Fix casting integer to string in `AbstractCommand::getRawSql()` (@Tigrov) ## 1.2.0 November 12, 2023 diff --git a/src/Command/AbstractCommand.php b/src/Command/AbstractCommand.php index dae234e46..10ba47fb6 100644 --- a/src/Command/AbstractCommand.php +++ b/src/Command/AbstractCommand.php @@ -351,7 +351,7 @@ public function getRawSql(): string $value = $param->getValue(); $params[$name] = match ($param->getType()) { - DataType::INTEGER => (string)$value, + DataType::INTEGER => (string)(int)$value, DataType::STRING, DataType::LOB => match (true) { $value instanceof Expression => (string)$value, is_resource($value) => $name, diff --git a/tests/Provider/CommandProvider.php b/tests/Provider/CommandProvider.php index 96156b8ae..4b1254c9c 100644 --- a/tests/Provider/CommandProvider.php +++ b/tests/Provider/CommandProvider.php @@ -4,6 +4,8 @@ namespace Yiisoft\Db\Tests\Provider; +use Yiisoft\Db\Command\DataType; +use Yiisoft\Db\Command\Param; use Yiisoft\Db\Expression\Expression; use Yiisoft\Db\Query\Query; use Yiisoft\Db\Schema\SchemaInterface; @@ -553,6 +555,18 @@ public static function rawSql(): array static::$driverName, ), ], + [ + << new Param('1 OR 1=1', DataType::INTEGER)], + DbHelper::replaceQuotes( + <<