Skip to content

Commit 17a3bad

Browse files
committed
Fix another literal handling
1 parent c0402ef commit 17a3bad

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/Type/Doctrine/Query/QueryResultTypeWalker.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,10 +1470,14 @@ public function walkLiteral($literal): string
14701470
if (stripos($value, 'e') !== false) {
14711471
$type = new ConstantFloatType((float) $value);
14721472
} else {
1473-
$type = new DqlConstantStringType((string) (float) $value, $literal->type);
1473+
$type = new DqlConstantStringType($value, $literal->type);
14741474
}
14751475
} elseif ($driver instanceof PgSQLDriver || $driver instanceof PdoPgSQLDriver) {
1476-
$type = new DqlConstantStringType((string) (float) $value, $literal->type);
1476+
if (stripos($value, 'e') !== false) {
1477+
$type = new DqlConstantStringType((string) (float) $value, $literal->type);
1478+
} else {
1479+
$type = new DqlConstantStringType($value, $literal->type);
1480+
}
14771481

14781482
} else {
14791483
$type = new ConstantFloatType((float) $value);

tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,22 @@ public static function provideCases(): iterable
171171
},
172172
];
173173

174+
yield ' 1.0' => [
175+
'data' => self::dataDefault(),
176+
'select' => 'SELECT 1.0 FROM %s t',
177+
'mysql' => new ConstantStringType('1.0'),
178+
'sqlite' => new ConstantFloatType(1.0),
179+
'pdo_pgsql' => new ConstantStringType('1.0'),
180+
'pgsql' => new ConstantStringType('1.0'),
181+
'mysqlResult' => '1.0',
182+
'sqliteResult' => 1.0,
183+
'pdoPgsqlResult' => '1.0',
184+
'pgsqlResult' => '1.0',
185+
'shouldStringify' => static function (Driver $driver, int $php, string $configName): bool {
186+
return self::defaultStringification($driver, $php, $configName);
187+
},
188+
];
189+
174190
yield ' 1e0' => [
175191
'data' => self::dataDefault(),
176192
'select' => 'SELECT 1e0 FROM %s t',

0 commit comments

Comments
 (0)