-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy internal SQLResultCasing from ORM
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Sonata Project package. | ||
* | ||
* (c) Thomas Rabaix <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace SimpleThings\EntityAudit\Utils; | ||
|
||
use Doctrine\DBAL\Platforms\AbstractPlatform; | ||
use Doctrine\DBAL\Platforms\DB2Platform; | ||
use Doctrine\DBAL\Platforms\OraclePlatform; | ||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform; | ||
|
||
/** | ||
* This trait is a copy of \Doctrine\ORM\Internal\SQLResultCasing. | ||
* | ||
* @see https://github.com/doctrine/orm/blob/8f7701279de84411020304f668cc8b49a5afbf5a/lib/Doctrine/ORM/Internal/SQLResultCasing.php | ||
* | ||
* @internal | ||
*/ | ||
trait SQLResultCasing | ||
{ | ||
private function getSQLResultCasing(AbstractPlatform $platform, string $column): string | ||
{ | ||
if ($platform instanceof DB2Platform || $platform instanceof OraclePlatform) { | ||
return strtoupper($column); | ||
} | ||
|
||
if ($platform instanceof PostgreSQLPlatform) { | ||
return strtolower($column); | ||
} | ||
|
||
if (method_exists($platform, 'getSQLResultCasing')) { | ||
return $platform->getSQLResultCasing($column); | ||
} | ||
|
||
return $column; | ||
} | ||
} |