vendor/doctrine/dbal/src/Platforms/AbstractPlatform.php line 4379

Open in your IDE?
  1. <?php
  2. namespace Doctrine\DBAL\Platforms;
  3. use Doctrine\Common\EventManager;
  4. use Doctrine\DBAL\Connection;
  5. use Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs;
  6. use Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs;
  7. use Doctrine\DBAL\Event\SchemaAlterTableEventArgs;
  8. use Doctrine\DBAL\Event\SchemaAlterTableRemoveColumnEventArgs;
  9. use Doctrine\DBAL\Event\SchemaAlterTableRenameColumnEventArgs;
  10. use Doctrine\DBAL\Event\SchemaCreateTableColumnEventArgs;
  11. use Doctrine\DBAL\Event\SchemaCreateTableEventArgs;
  12. use Doctrine\DBAL\Event\SchemaDropTableEventArgs;
  13. use Doctrine\DBAL\Events;
  14. use Doctrine\DBAL\Exception;
  15. use Doctrine\DBAL\Exception\InvalidLockMode;
  16. use Doctrine\DBAL\LockMode;
  17. use Doctrine\DBAL\Platforms\Keywords\KeywordList;
  18. use Doctrine\DBAL\Schema\AbstractSchemaManager;
  19. use Doctrine\DBAL\Schema\Column;
  20. use Doctrine\DBAL\Schema\ColumnDiff;
  21. use Doctrine\DBAL\Schema\Constraint;
  22. use Doctrine\DBAL\Schema\ForeignKeyConstraint;
  23. use Doctrine\DBAL\Schema\Identifier;
  24. use Doctrine\DBAL\Schema\Index;
  25. use Doctrine\DBAL\Schema\SchemaDiff;
  26. use Doctrine\DBAL\Schema\Sequence;
  27. use Doctrine\DBAL\Schema\Table;
  28. use Doctrine\DBAL\Schema\TableDiff;
  29. use Doctrine\DBAL\Schema\UniqueConstraint;
  30. use Doctrine\DBAL\SQL\Builder\DefaultSelectSQLBuilder;
  31. use Doctrine\DBAL\SQL\Builder\SelectSQLBuilder;
  32. use Doctrine\DBAL\SQL\Parser;
  33. use Doctrine\DBAL\TransactionIsolationLevel;
  34. use Doctrine\DBAL\Types;
  35. use Doctrine\DBAL\Types\Type;
  36. use Doctrine\Deprecations\Deprecation;
  37. use InvalidArgumentException;
  38. use UnexpectedValueException;
  39. use function addcslashes;
  40. use function array_map;
  41. use function array_merge;
  42. use function array_unique;
  43. use function array_values;
  44. use function assert;
  45. use function count;
  46. use function explode;
  47. use function func_get_arg;
  48. use function func_get_args;
  49. use function func_num_args;
  50. use function implode;
  51. use function in_array;
  52. use function is_array;
  53. use function is_bool;
  54. use function is_int;
  55. use function is_string;
  56. use function preg_quote;
  57. use function preg_replace;
  58. use function sprintf;
  59. use function str_replace;
  60. use function strlen;
  61. use function strpos;
  62. use function strtolower;
  63. use function strtoupper;
  64. /**
  65.  * Base class for all DatabasePlatforms. The DatabasePlatforms are the central
  66.  * point of abstraction of platform-specific behaviors, features and SQL dialects.
  67.  * They are a passive source of information.
  68.  *
  69.  * @todo Remove any unnecessary methods.
  70.  */
  71. abstract class AbstractPlatform
  72. {
  73.     public const CREATE_INDEXES 1;
  74.     public const CREATE_FOREIGNKEYS 2;
  75.     /** @var string[]|null */
  76.     protected $doctrineTypeMapping;
  77.     /**
  78.      * Contains a list of all columns that should generate parseable column comments for type-detection
  79.      * in reverse engineering scenarios.
  80.      *
  81.      * @deprecated This property is deprecated and will be removed in Doctrine DBAL 4.0.
  82.      *
  83.      * @var string[]|null
  84.      */
  85.     protected $doctrineTypeComments;
  86.     /**
  87.      * @deprecated
  88.      *
  89.      * @var EventManager|null
  90.      */
  91.     protected $_eventManager;
  92.     /**
  93.      * Holds the KeywordList instance for the current platform.
  94.      *
  95.      * @var KeywordList|null
  96.      */
  97.     protected $_keywords;
  98.     private bool $disableTypeComments false;
  99.     /** @internal */
  100.     final public function setDisableTypeComments(bool $value): void
  101.     {
  102.         $this->disableTypeComments $value;
  103.     }
  104.     /**
  105.      * Sets the EventManager used by the Platform.
  106.      *
  107.      * @deprecated
  108.      *
  109.      * @return void
  110.      */
  111.     public function setEventManager(EventManager $eventManager)
  112.     {
  113.         Deprecation::triggerIfCalledFromOutside(
  114.             'doctrine/dbal',
  115.             'https://github.com/doctrine/dbal/issues/5784',
  116.             '%s is deprecated.',
  117.             __METHOD__,
  118.         );
  119.         $this->_eventManager $eventManager;
  120.     }
  121.     /**
  122.      * Gets the EventManager used by the Platform.
  123.      *
  124.      * @deprecated
  125.      *
  126.      * @return EventManager|null
  127.      */
  128.     public function getEventManager()
  129.     {
  130.         Deprecation::triggerIfCalledFromOutside(
  131.             'doctrine/dbal',
  132.             'https://github.com/doctrine/dbal/issues/5784',
  133.             '%s is deprecated.',
  134.             __METHOD__,
  135.         );
  136.         return $this->_eventManager;
  137.     }
  138.     /**
  139.      * Returns the SQL snippet that declares a boolean column.
  140.      *
  141.      * @param mixed[] $column
  142.      *
  143.      * @return string
  144.      */
  145.     abstract public function getBooleanTypeDeclarationSQL(array $column);
  146.     /**
  147.      * Returns the SQL snippet that declares a 4 byte integer column.
  148.      *
  149.      * @param mixed[] $column
  150.      *
  151.      * @return string
  152.      */
  153.     abstract public function getIntegerTypeDeclarationSQL(array $column);
  154.     /**
  155.      * Returns the SQL snippet that declares an 8 byte integer column.
  156.      *
  157.      * @param mixed[] $column
  158.      *
  159.      * @return string
  160.      */
  161.     abstract public function getBigIntTypeDeclarationSQL(array $column);
  162.     /**
  163.      * Returns the SQL snippet that declares a 2 byte integer column.
  164.      *
  165.      * @param mixed[] $column
  166.      *
  167.      * @return string
  168.      */
  169.     abstract public function getSmallIntTypeDeclarationSQL(array $column);
  170.     /**
  171.      * Returns the SQL snippet that declares common properties of an integer column.
  172.      *
  173.      * @param mixed[] $column
  174.      *
  175.      * @return string
  176.      */
  177.     abstract protected function _getCommonIntegerTypeDeclarationSQL(array $column);
  178.     /**
  179.      * Lazy load Doctrine Type Mappings.
  180.      *
  181.      * @return void
  182.      */
  183.     abstract protected function initializeDoctrineTypeMappings();
  184.     /**
  185.      * Initializes Doctrine Type Mappings with the platform defaults
  186.      * and with all additional type mappings.
  187.      */
  188.     private function initializeAllDoctrineTypeMappings(): void
  189.     {
  190.         $this->initializeDoctrineTypeMappings();
  191.         foreach (Type::getTypesMap() as $typeName => $className) {
  192.             foreach (Type::getType($typeName)->getMappedDatabaseTypes($this) as $dbType) {
  193.                 $dbType                             strtolower($dbType);
  194.                 $this->doctrineTypeMapping[$dbType] = $typeName;
  195.             }
  196.         }
  197.     }
  198.     /**
  199.      * Returns the SQL snippet used to declare a column that can
  200.      * store characters in the ASCII character set
  201.      *
  202.      * @param mixed[] $column
  203.      */
  204.     public function getAsciiStringTypeDeclarationSQL(array $column): string
  205.     {
  206.         return $this->getStringTypeDeclarationSQL($column);
  207.     }
  208.     /**
  209.      * Returns the SQL snippet used to declare a VARCHAR column type.
  210.      *
  211.      * @deprecated Use {@link getStringTypeDeclarationSQL()} instead.
  212.      *
  213.      * @param mixed[] $column
  214.      *
  215.      * @return string
  216.      */
  217.     public function getVarcharTypeDeclarationSQL(array $column)
  218.     {
  219.         if (isset($column['length'])) {
  220.             $lengthOmitted false;
  221.         } else {
  222.             $column['length'] = $this->getVarcharDefaultLength();
  223.             $lengthOmitted    true;
  224.         }
  225.         $fixed $column['fixed'] ?? false;
  226.         $maxLength $fixed
  227.             $this->getCharMaxLength()
  228.             : $this->getVarcharMaxLength();
  229.         if ($column['length'] > $maxLength) {
  230.             return $this->getClobTypeDeclarationSQL($column);
  231.         }
  232.         return $this->getVarcharTypeDeclarationSQLSnippet($column['length'], $fixed$lengthOmitted);
  233.     }
  234.     /**
  235.      * Returns the SQL snippet used to declare a string column type.
  236.      *
  237.      * @param mixed[] $column
  238.      *
  239.      * @return string
  240.      */
  241.     public function getStringTypeDeclarationSQL(array $column)
  242.     {
  243.         return $this->getVarcharTypeDeclarationSQL($column);
  244.     }
  245.     /**
  246.      * Returns the SQL snippet used to declare a BINARY/VARBINARY column type.
  247.      *
  248.      * @param mixed[] $column The column definition.
  249.      *
  250.      * @return string
  251.      */
  252.     public function getBinaryTypeDeclarationSQL(array $column)
  253.     {
  254.         if (isset($column['length'])) {
  255.             $lengthOmitted false;
  256.         } else {
  257.             $column['length'] = $this->getBinaryDefaultLength();
  258.             $lengthOmitted    true;
  259.         }
  260.         $fixed $column['fixed'] ?? false;
  261.         $maxLength $this->getBinaryMaxLength();
  262.         if ($column['length'] > $maxLength) {
  263.             if ($maxLength 0) {
  264.                 Deprecation::trigger(
  265.                     'doctrine/dbal',
  266.                     'https://github.com/doctrine/dbal/issues/3187',
  267.                     'Binary column length %d is greater than supported by the platform (%d).'
  268.                         ' Reduce the column length or use a BLOB column instead.',
  269.                     $column['length'],
  270.                     $maxLength,
  271.                 );
  272.             }
  273.             return $this->getBlobTypeDeclarationSQL($column);
  274.         }
  275.         return $this->getBinaryTypeDeclarationSQLSnippet($column['length'], $fixed$lengthOmitted);
  276.     }
  277.     /**
  278.      * Returns the SQL snippet to declare a GUID/UUID column.
  279.      *
  280.      * By default this maps directly to a CHAR(36) and only maps to more
  281.      * special datatypes when the underlying databases support this datatype.
  282.      *
  283.      * @param mixed[] $column
  284.      *
  285.      * @return string
  286.      */
  287.     public function getGuidTypeDeclarationSQL(array $column)
  288.     {
  289.         $column['length'] = 36;
  290.         $column['fixed']  = true;
  291.         return $this->getStringTypeDeclarationSQL($column);
  292.     }
  293.     /**
  294.      * Returns the SQL snippet to declare a JSON column.
  295.      *
  296.      * By default this maps directly to a CLOB and only maps to more
  297.      * special datatypes when the underlying databases support this datatype.
  298.      *
  299.      * @param mixed[] $column
  300.      *
  301.      * @return string
  302.      */
  303.     public function getJsonTypeDeclarationSQL(array $column)
  304.     {
  305.         return $this->getClobTypeDeclarationSQL($column);
  306.     }
  307.     /**
  308.      * @param int|false $length
  309.      * @param bool      $fixed
  310.      *
  311.      * @return string
  312.      *
  313.      * @throws Exception If not supported on this platform.
  314.      */
  315.     protected function getVarcharTypeDeclarationSQLSnippet($length$fixed/*, $lengthOmitted = false*/)
  316.     {
  317.         throw Exception::notSupported('VARCHARs not supported by Platform.');
  318.     }
  319.     /**
  320.      * Returns the SQL snippet used to declare a BINARY/VARBINARY column type.
  321.      *
  322.      * @param int|false $length The length of the column.
  323.      * @param bool      $fixed  Whether the column length is fixed.
  324.      *
  325.      * @return string
  326.      *
  327.      * @throws Exception If not supported on this platform.
  328.      */
  329.     protected function getBinaryTypeDeclarationSQLSnippet($length$fixed/*, $lengthOmitted = false*/)
  330.     {
  331.         throw Exception::notSupported('BINARY/VARBINARY column types are not supported by this platform.');
  332.     }
  333.     /**
  334.      * Returns the SQL snippet used to declare a CLOB column type.
  335.      *
  336.      * @param mixed[] $column
  337.      *
  338.      * @return string
  339.      */
  340.     abstract public function getClobTypeDeclarationSQL(array $column);
  341.     /**
  342.      * Returns the SQL Snippet used to declare a BLOB column type.
  343.      *
  344.      * @param mixed[] $column
  345.      *
  346.      * @return string
  347.      */
  348.     abstract public function getBlobTypeDeclarationSQL(array $column);
  349.     /**
  350.      * Gets the name of the platform.
  351.      *
  352.      * @deprecated Identify platforms by their class.
  353.      *
  354.      * @return string
  355.      */
  356.     abstract public function getName();
  357.     /**
  358.      * Registers a doctrine type to be used in conjunction with a column type of this platform.
  359.      *
  360.      * @param string $dbType
  361.      * @param string $doctrineType
  362.      *
  363.      * @return void
  364.      *
  365.      * @throws Exception If the type is not found.
  366.      */
  367.     public function registerDoctrineTypeMapping($dbType$doctrineType)
  368.     {
  369.         if ($this->doctrineTypeMapping === null) {
  370.             $this->initializeAllDoctrineTypeMappings();
  371.         }
  372.         if (! Types\Type::hasType($doctrineType)) {
  373.             throw Exception::typeNotFound($doctrineType);
  374.         }
  375.         $dbType                             strtolower($dbType);
  376.         $this->doctrineTypeMapping[$dbType] = $doctrineType;
  377.         $doctrineType Type::getType($doctrineType);
  378.         if (! $doctrineType->requiresSQLCommentHint($this)) {
  379.             return;
  380.         }
  381.         $this->markDoctrineTypeCommented($doctrineType);
  382.     }
  383.     /**
  384.      * Gets the Doctrine type that is mapped for the given database column type.
  385.      *
  386.      * @param string $dbType
  387.      *
  388.      * @return string
  389.      *
  390.      * @throws Exception
  391.      */
  392.     public function getDoctrineTypeMapping($dbType)
  393.     {
  394.         if ($this->doctrineTypeMapping === null) {
  395.             $this->initializeAllDoctrineTypeMappings();
  396.         }
  397.         $dbType strtolower($dbType);
  398.         if (! isset($this->doctrineTypeMapping[$dbType])) {
  399.             throw new Exception(
  400.                 'Unknown database type ' $dbType ' requested, ' . static::class . ' may not support it.',
  401.             );
  402.         }
  403.         return $this->doctrineTypeMapping[$dbType];
  404.     }
  405.     /**
  406.      * Checks if a database type is currently supported by this platform.
  407.      *
  408.      * @param string $dbType
  409.      *
  410.      * @return bool
  411.      */
  412.     public function hasDoctrineTypeMappingFor($dbType)
  413.     {
  414.         if ($this->doctrineTypeMapping === null) {
  415.             $this->initializeAllDoctrineTypeMappings();
  416.         }
  417.         $dbType strtolower($dbType);
  418.         return isset($this->doctrineTypeMapping[$dbType]);
  419.     }
  420.     /**
  421.      * Initializes the Doctrine Type comments instance variable for in_array() checks.
  422.      *
  423.      * @deprecated This API will be removed in Doctrine DBAL 4.0.
  424.      *
  425.      * @return void
  426.      */
  427.     protected function initializeCommentedDoctrineTypes()
  428.     {
  429.         Deprecation::triggerIfCalledFromOutside(
  430.             'doctrine/dbal',
  431.             'https://github.com/doctrine/dbal/pull/5058',
  432.             '%s is deprecated and will be removed in Doctrine DBAL 4.0.',
  433.             __METHOD__,
  434.         );
  435.         $this->doctrineTypeComments = [];
  436.         foreach (Type::getTypesMap() as $typeName => $className) {
  437.             $type Type::getType($typeName);
  438.             if (! $type->requiresSQLCommentHint($this)) {
  439.                 continue;
  440.             }
  441.             $this->doctrineTypeComments[] = $typeName;
  442.         }
  443.     }
  444.     /**
  445.      * Is it necessary for the platform to add a parsable type comment to allow reverse engineering the given type?
  446.      *
  447.      * @deprecated Use {@link Type::requiresSQLCommentHint()} instead.
  448.      *
  449.      * @return bool
  450.      */
  451.     public function isCommentedDoctrineType(Type $doctrineType)
  452.     {
  453.         Deprecation::triggerIfCalledFromOutside(
  454.             'doctrine/dbal',
  455.             'https://github.com/doctrine/dbal/pull/5058',
  456.             '%s is deprecated and will be removed in Doctrine DBAL 4.0. Use Type::requiresSQLCommentHint() instead.',
  457.             __METHOD__,
  458.         );
  459.         if ($this->doctrineTypeComments === null) {
  460.             $this->initializeCommentedDoctrineTypes();
  461.         }
  462.         return $doctrineType->requiresSQLCommentHint($this);
  463.     }
  464.     /**
  465.      * Marks this type as to be commented in ALTER TABLE and CREATE TABLE statements.
  466.      *
  467.      * @param string|Type $doctrineType
  468.      *
  469.      * @return void
  470.      */
  471.     public function markDoctrineTypeCommented($doctrineType)
  472.     {
  473.         Deprecation::triggerIfCalledFromOutside(
  474.             'doctrine/dbal',
  475.             'https://github.com/doctrine/dbal/pull/5058',
  476.             '%s is deprecated and will be removed in Doctrine DBAL 4.0. Use Type::requiresSQLCommentHint() instead.',
  477.             __METHOD__,
  478.         );
  479.         if ($this->doctrineTypeComments === null) {
  480.             $this->initializeCommentedDoctrineTypes();
  481.         }
  482.         assert(is_array($this->doctrineTypeComments));
  483.         $this->doctrineTypeComments[] = $doctrineType instanceof Type $doctrineType->getName() : $doctrineType;
  484.     }
  485.     /**
  486.      * Gets the comment to append to a column comment that helps parsing this type in reverse engineering.
  487.      *
  488.      * @deprecated This method will be removed without replacement.
  489.      *
  490.      * @return string
  491.      */
  492.     public function getDoctrineTypeComment(Type $doctrineType)
  493.     {
  494.         Deprecation::triggerIfCalledFromOutside(
  495.             'doctrine/dbal',
  496.             'https://github.com/doctrine/dbal/pull/5107',
  497.             '%s is deprecated and will be removed in Doctrine DBAL 4.0.',
  498.             __METHOD__,
  499.         );
  500.         return '(DC2Type:' $doctrineType->getName() . ')';
  501.     }
  502.     /**
  503.      * Gets the comment of a passed column modified by potential doctrine type comment hints.
  504.      *
  505.      * @deprecated This method will be removed without replacement.
  506.      *
  507.      * @return string|null
  508.      */
  509.     protected function getColumnComment(Column $column)
  510.     {
  511.         Deprecation::triggerIfCalledFromOutside(
  512.             'doctrine/dbal',
  513.             'https://github.com/doctrine/dbal/pull/5107',
  514.             '%s is deprecated and will be removed in Doctrine DBAL 4.0.',
  515.             __METHOD__,
  516.         );
  517.         $comment $column->getComment();
  518.         if (! $this->disableTypeComments && $column->getType()->requiresSQLCommentHint($this)) {
  519.             $comment .= $this->getDoctrineTypeComment($column->getType());
  520.         }
  521.         return $comment;
  522.     }
  523.     /**
  524.      * Gets the character used for identifier quoting.
  525.      *
  526.      * @deprecated Use {@see quoteIdentifier()} to quote identifiers instead.
  527.      *
  528.      * @return string
  529.      */
  530.     public function getIdentifierQuoteCharacter()
  531.     {
  532.         Deprecation::triggerIfCalledFromOutside(
  533.             'doctrine/dbal',
  534.             'https://github.com/doctrine/dbal/pull/5388',
  535.             'AbstractPlatform::getIdentifierQuoteCharacter() is deprecated. Use quoteIdentifier() instead.',
  536.         );
  537.         return '"';
  538.     }
  539.     /**
  540.      * Gets the string portion that starts an SQL comment.
  541.      *
  542.      * @deprecated
  543.      *
  544.      * @return string
  545.      */
  546.     public function getSqlCommentStartString()
  547.     {
  548.         Deprecation::trigger(
  549.             'doctrine/dbal',
  550.             'https://github.com/doctrine/dbal/pull/4724',
  551.             'AbstractPlatform::getSqlCommentStartString() is deprecated.',
  552.         );
  553.         return '--';
  554.     }
  555.     /**
  556.      * Gets the string portion that ends an SQL comment.
  557.      *
  558.      * @deprecated
  559.      *
  560.      * @return string
  561.      */
  562.     public function getSqlCommentEndString()
  563.     {
  564.         Deprecation::trigger(
  565.             'doctrine/dbal',
  566.             'https://github.com/doctrine/dbal/pull/4724',
  567.             'AbstractPlatform::getSqlCommentEndString() is deprecated.',
  568.         );
  569.         return "\n";
  570.     }
  571.     /**
  572.      * Gets the maximum length of a char column.
  573.      *
  574.      * @deprecated
  575.      */
  576.     public function getCharMaxLength(): int
  577.     {
  578.         Deprecation::triggerIfCalledFromOutside(
  579.             'doctrine/dbal',
  580.             'https://github.com/doctrine/dbal/issues/3263',
  581.             'AbstractPlatform::getCharMaxLength() is deprecated.',
  582.         );
  583.         return $this->getVarcharMaxLength();
  584.     }
  585.     /**
  586.      * Gets the maximum length of a varchar column.
  587.      *
  588.      * @deprecated
  589.      *
  590.      * @return int
  591.      */
  592.     public function getVarcharMaxLength()
  593.     {
  594.         Deprecation::triggerIfCalledFromOutside(
  595.             'doctrine/dbal',
  596.             'https://github.com/doctrine/dbal/issues/3263',
  597.             'AbstractPlatform::getVarcharMaxLength() is deprecated.',
  598.         );
  599.         return 4000;
  600.     }
  601.     /**
  602.      * Gets the default length of a varchar column.
  603.      *
  604.      * @deprecated
  605.      *
  606.      * @return int
  607.      */
  608.     public function getVarcharDefaultLength()
  609.     {
  610.         Deprecation::triggerIfCalledFromOutside(
  611.             'doctrine/dbal',
  612.             'https://github.com/doctrine/dbal/issues/3263',
  613.             'Relying on the default varchar column length is deprecated, specify the length explicitly.',
  614.         );
  615.         return 255;
  616.     }
  617.     /**
  618.      * Gets the maximum length of a binary column.
  619.      *
  620.      * @deprecated
  621.      *
  622.      * @return int
  623.      */
  624.     public function getBinaryMaxLength()
  625.     {
  626.         Deprecation::triggerIfCalledFromOutside(
  627.             'doctrine/dbal',
  628.             'https://github.com/doctrine/dbal/issues/3263',
  629.             'AbstractPlatform::getBinaryMaxLength() is deprecated.',
  630.         );
  631.         return 4000;
  632.     }
  633.     /**
  634.      * Gets the default length of a binary column.
  635.      *
  636.      * @deprecated
  637.      *
  638.      * @return int
  639.      */
  640.     public function getBinaryDefaultLength()
  641.     {
  642.         Deprecation::trigger(
  643.             'doctrine/dbal',
  644.             'https://github.com/doctrine/dbal/issues/3263',
  645.             'Relying on the default binary column length is deprecated, specify the length explicitly.',
  646.         );
  647.         return 255;
  648.     }
  649.     /**
  650.      * Gets all SQL wildcard characters of the platform.
  651.      *
  652.      * @deprecated Use {@see AbstractPlatform::getLikeWildcardCharacters()} instead.
  653.      *
  654.      * @return string[]
  655.      */
  656.     public function getWildcards()
  657.     {
  658.         Deprecation::trigger(
  659.             'doctrine/dbal',
  660.             'https://github.com/doctrine/dbal/pull/4724',
  661.             'AbstractPlatform::getWildcards() is deprecated.'
  662.             ' Use AbstractPlatform::getLikeWildcardCharacters() instead.',
  663.         );
  664.         return ['%''_'];
  665.     }
  666.     /**
  667.      * Returns the regular expression operator.
  668.      *
  669.      * @return string
  670.      *
  671.      * @throws Exception If not supported on this platform.
  672.      */
  673.     public function getRegexpExpression()
  674.     {
  675.         throw Exception::notSupported(__METHOD__);
  676.     }
  677.     /**
  678.      * Returns the SQL snippet to get the average value of a column.
  679.      *
  680.      * @deprecated Use AVG() in SQL instead.
  681.      *
  682.      * @param string $column The column to use.
  683.      *
  684.      * @return string Generated SQL including an AVG aggregate function.
  685.      */
  686.     public function getAvgExpression($column)
  687.     {
  688.         Deprecation::trigger(
  689.             'doctrine/dbal',
  690.             'https://github.com/doctrine/dbal/pull/4724',
  691.             'AbstractPlatform::getAvgExpression() is deprecated. Use AVG() in SQL instead.',
  692.         );
  693.         return 'AVG(' $column ')';
  694.     }
  695.     /**
  696.      * Returns the SQL snippet to get the number of rows (without a NULL value) of a column.
  697.      *
  698.      * If a '*' is used instead of a column the number of selected rows is returned.
  699.      *
  700.      * @deprecated Use COUNT() in SQL instead.
  701.      *
  702.      * @param string|int $column The column to use.
  703.      *
  704.      * @return string Generated SQL including a COUNT aggregate function.
  705.      */
  706.     public function getCountExpression($column)
  707.     {
  708.         Deprecation::trigger(
  709.             'doctrine/dbal',
  710.             'https://github.com/doctrine/dbal/pull/4724',
  711.             'AbstractPlatform::getCountExpression() is deprecated. Use COUNT() in SQL instead.',
  712.         );
  713.         return 'COUNT(' $column ')';
  714.     }
  715.     /**
  716.      * Returns the SQL snippet to get the highest value of a column.
  717.      *
  718.      * @deprecated Use MAX() in SQL instead.
  719.      *
  720.      * @param string $column The column to use.
  721.      *
  722.      * @return string Generated SQL including a MAX aggregate function.
  723.      */
  724.     public function getMaxExpression($column)
  725.     {
  726.         Deprecation::trigger(
  727.             'doctrine/dbal',
  728.             'https://github.com/doctrine/dbal/pull/4724',
  729.             'AbstractPlatform::getMaxExpression() is deprecated. Use MAX() in SQL instead.',
  730.         );
  731.         return 'MAX(' $column ')';
  732.     }
  733.     /**
  734.      * Returns the SQL snippet to get the lowest value of a column.
  735.      *
  736.      * @deprecated Use MIN() in SQL instead.
  737.      *
  738.      * @param string $column The column to use.
  739.      *
  740.      * @return string Generated SQL including a MIN aggregate function.
  741.      */
  742.     public function getMinExpression($column)
  743.     {
  744.         Deprecation::trigger(
  745.             'doctrine/dbal',
  746.             'https://github.com/doctrine/dbal/pull/4724',
  747.             'AbstractPlatform::getMinExpression() is deprecated. Use MIN() in SQL instead.',
  748.         );
  749.         return 'MIN(' $column ')';
  750.     }
  751.     /**
  752.      * Returns the SQL snippet to get the total sum of a column.
  753.      *
  754.      * @deprecated Use SUM() in SQL instead.
  755.      *
  756.      * @param string $column The column to use.
  757.      *
  758.      * @return string Generated SQL including a SUM aggregate function.
  759.      */
  760.     public function getSumExpression($column)
  761.     {
  762.         Deprecation::trigger(
  763.             'doctrine/dbal',
  764.             'https://github.com/doctrine/dbal/pull/4724',
  765.             'AbstractPlatform::getSumExpression() is deprecated. Use SUM() in SQL instead.',
  766.         );
  767.         return 'SUM(' $column ')';
  768.     }
  769.     // scalar functions
  770.     /**
  771.      * Returns the SQL snippet to get the md5 sum of a column.
  772.      *
  773.      * Note: Not SQL92, but common functionality.
  774.      *
  775.      * @deprecated
  776.      *
  777.      * @param string $column
  778.      *
  779.      * @return string
  780.      */
  781.     public function getMd5Expression($column)
  782.     {
  783.         Deprecation::trigger(
  784.             'doctrine/dbal',
  785.             'https://github.com/doctrine/dbal/pull/4724',
  786.             'AbstractPlatform::getMd5Expression() is deprecated.',
  787.         );
  788.         return 'MD5(' $column ')';
  789.     }
  790.     /**
  791.      * Returns the SQL snippet to get the length of a text column in characters.
  792.      *
  793.      * @param string $column
  794.      *
  795.      * @return string
  796.      */
  797.     public function getLengthExpression($column)
  798.     {
  799.         return 'LENGTH(' $column ')';
  800.     }
  801.     /**
  802.      * Returns the SQL snippet to get the squared value of a column.
  803.      *
  804.      * @deprecated Use SQRT() in SQL instead.
  805.      *
  806.      * @param string $column The column to use.
  807.      *
  808.      * @return string Generated SQL including an SQRT aggregate function.
  809.      */
  810.     public function getSqrtExpression($column)
  811.     {
  812.         Deprecation::trigger(
  813.             'doctrine/dbal',
  814.             'https://github.com/doctrine/dbal/pull/4724',
  815.             'AbstractPlatform::getSqrtExpression() is deprecated. Use SQRT() in SQL instead.',
  816.         );
  817.         return 'SQRT(' $column ')';
  818.     }
  819.     /**
  820.      * Returns the SQL snippet to round a numeric column to the number of decimals specified.
  821.      *
  822.      * @deprecated Use ROUND() in SQL instead.
  823.      *
  824.      * @param string     $column
  825.      * @param string|int $decimals
  826.      *
  827.      * @return string
  828.      */
  829.     public function getRoundExpression($column$decimals 0)
  830.     {
  831.         Deprecation::trigger(
  832.             'doctrine/dbal',
  833.             'https://github.com/doctrine/dbal/pull/4724',
  834.             'AbstractPlatform::getRoundExpression() is deprecated. Use ROUND() in SQL instead.',
  835.         );
  836.         return 'ROUND(' $column ', ' $decimals ')';
  837.     }
  838.     /**
  839.      * Returns the SQL snippet to get the remainder of the division operation $expression1 / $expression2.
  840.      *
  841.      * @param string $expression1
  842.      * @param string $expression2
  843.      *
  844.      * @return string
  845.      */
  846.     public function getModExpression($expression1$expression2)
  847.     {
  848.         return 'MOD(' $expression1 ', ' $expression2 ')';
  849.     }
  850.     /**
  851.      * Returns the SQL snippet to trim a string.
  852.      *
  853.      * @param string      $str  The expression to apply the trim to.
  854.      * @param int         $mode The position of the trim (leading/trailing/both).
  855.      * @param string|bool $char The char to trim, has to be quoted already. Defaults to space.
  856.      *
  857.      * @return string
  858.      */
  859.     public function getTrimExpression($str$mode TrimMode::UNSPECIFIED$char false)
  860.     {
  861.         $expression '';
  862.         switch ($mode) {
  863.             case TrimMode::LEADING:
  864.                 $expression 'LEADING ';
  865.                 break;
  866.             case TrimMode::TRAILING:
  867.                 $expression 'TRAILING ';
  868.                 break;
  869.             case TrimMode::BOTH:
  870.                 $expression 'BOTH ';
  871.                 break;
  872.         }
  873.         if ($char !== false) {
  874.             $expression .= $char ' ';
  875.         }
  876.         if ($mode !== TrimMode::UNSPECIFIED || $char !== false) {
  877.             $expression .= 'FROM ';
  878.         }
  879.         return 'TRIM(' $expression $str ')';
  880.     }
  881.     /**
  882.      * Returns the SQL snippet to trim trailing space characters from the expression.
  883.      *
  884.      * @deprecated Use RTRIM() in SQL instead.
  885.      *
  886.      * @param string $str Literal string or column name.
  887.      *
  888.      * @return string
  889.      */
  890.     public function getRtrimExpression($str)
  891.     {
  892.         Deprecation::trigger(
  893.             'doctrine/dbal',
  894.             'https://github.com/doctrine/dbal/pull/4724',
  895.             'AbstractPlatform::getRtrimExpression() is deprecated. Use RTRIM() in SQL instead.',
  896.         );
  897.         return 'RTRIM(' $str ')';
  898.     }
  899.     /**
  900.      * Returns the SQL snippet to trim leading space characters from the expression.
  901.      *
  902.      * @deprecated Use LTRIM() in SQL instead.
  903.      *
  904.      * @param string $str Literal string or column name.
  905.      *
  906.      * @return string
  907.      */
  908.     public function getLtrimExpression($str)
  909.     {
  910.         Deprecation::trigger(
  911.             'doctrine/dbal',
  912.             'https://github.com/doctrine/dbal/pull/4724',
  913.             'AbstractPlatform::getLtrimExpression() is deprecated. Use LTRIM() in SQL instead.',
  914.         );
  915.         return 'LTRIM(' $str ')';
  916.     }
  917.     /**
  918.      * Returns the SQL snippet to change all characters from the expression to uppercase,
  919.      * according to the current character set mapping.
  920.      *
  921.      * @deprecated Use UPPER() in SQL instead.
  922.      *
  923.      * @param string $str Literal string or column name.
  924.      *
  925.      * @return string
  926.      */
  927.     public function getUpperExpression($str)
  928.     {
  929.         Deprecation::trigger(
  930.             'doctrine/dbal',
  931.             'https://github.com/doctrine/dbal/pull/4724',
  932.             'AbstractPlatform::getUpperExpression() is deprecated. Use UPPER() in SQL instead.',
  933.         );
  934.         return 'UPPER(' $str ')';
  935.     }
  936.     /**
  937.      * Returns the SQL snippet to change all characters from the expression to lowercase,
  938.      * according to the current character set mapping.
  939.      *
  940.      * @deprecated Use LOWER() in SQL instead.
  941.      *
  942.      * @param string $str Literal string or column name.
  943.      *
  944.      * @return string
  945.      */
  946.     public function getLowerExpression($str)
  947.     {
  948.         Deprecation::trigger(
  949.             'doctrine/dbal',
  950.             'https://github.com/doctrine/dbal/pull/4724',
  951.             'AbstractPlatform::getLowerExpression() is deprecated. Use LOWER() in SQL instead.',
  952.         );
  953.         return 'LOWER(' $str ')';
  954.     }
  955.     /**
  956.      * Returns the SQL snippet to get the position of the first occurrence of substring $substr in string $str.
  957.      *
  958.      * @param string           $str      Literal string.
  959.      * @param string           $substr   Literal string to find.
  960.      * @param string|int|false $startPos Position to start at, beginning of string by default.
  961.      *
  962.      * @return string
  963.      *
  964.      * @throws Exception If not supported on this platform.
  965.      */
  966.     public function getLocateExpression($str$substr$startPos false)
  967.     {
  968.         throw Exception::notSupported(__METHOD__);
  969.     }
  970.     /**
  971.      * Returns the SQL snippet to get the current system date.
  972.      *
  973.      * @deprecated Generate dates within the application.
  974.      *
  975.      * @return string
  976.      */
  977.     public function getNowExpression()
  978.     {
  979.         Deprecation::trigger(
  980.             'doctrine/dbal',
  981.             'https://github.com/doctrine/dbal/pull/4753',
  982.             'AbstractPlatform::getNowExpression() is deprecated. Generate dates within the application.',
  983.         );
  984.         return 'NOW()';
  985.     }
  986.     /**
  987.      * Returns a SQL snippet to get a substring inside an SQL statement.
  988.      *
  989.      * Note: Not SQL92, but common functionality.
  990.      *
  991.      * SQLite only supports the 2 parameter variant of this function.
  992.      *
  993.      * @param string          $string An sql string literal or column name/alias.
  994.      * @param string|int      $start  Where to start the substring portion.
  995.      * @param string|int|null $length The substring portion length.
  996.      *
  997.      * @return string
  998.      */
  999.     public function getSubstringExpression($string$start$length null)
  1000.     {
  1001.         if ($length === null) {
  1002.             return 'SUBSTRING(' $string ' FROM ' $start ')';
  1003.         }
  1004.         return 'SUBSTRING(' $string ' FROM ' $start ' FOR ' $length ')';
  1005.     }
  1006.     /**
  1007.      * Returns a SQL snippet to concatenate the given expressions.
  1008.      *
  1009.      * Accepts an arbitrary number of string parameters. Each parameter must contain an expression.
  1010.      *
  1011.      * @return string
  1012.      */
  1013.     public function getConcatExpression()
  1014.     {
  1015.         return implode(' || 'func_get_args());
  1016.     }
  1017.     /**
  1018.      * Returns the SQL for a logical not.
  1019.      *
  1020.      * Example:
  1021.      * <code>
  1022.      * $q = new Doctrine_Query();
  1023.      * $e = $q->expr;
  1024.      * $q->select('*')->from('table')
  1025.      *   ->where($e->eq('id', $e->not('null'));
  1026.      * </code>
  1027.      *
  1028.      * @deprecated Use NOT() in SQL instead.
  1029.      *
  1030.      * @param string $expression
  1031.      *
  1032.      * @return string The logical expression.
  1033.      */
  1034.     public function getNotExpression($expression)
  1035.     {
  1036.         Deprecation::trigger(
  1037.             'doctrine/dbal',
  1038.             'https://github.com/doctrine/dbal/pull/4724',
  1039.             'AbstractPlatform::getNotExpression() is deprecated. Use NOT() in SQL instead.',
  1040.         );
  1041.         return 'NOT(' $expression ')';
  1042.     }
  1043.     /**
  1044.      * Returns the SQL that checks if an expression is null.
  1045.      *
  1046.      * @deprecated Use IS NULL in SQL instead.
  1047.      *
  1048.      * @param string $expression The expression that should be compared to null.
  1049.      *
  1050.      * @return string The logical expression.
  1051.      */
  1052.     public function getIsNullExpression($expression)
  1053.     {
  1054.         Deprecation::trigger(
  1055.             'doctrine/dbal',
  1056.             'https://github.com/doctrine/dbal/pull/4724',
  1057.             'AbstractPlatform::getIsNullExpression() is deprecated. Use IS NULL in SQL instead.',
  1058.         );
  1059.         return $expression ' IS NULL';
  1060.     }
  1061.     /**
  1062.      * Returns the SQL that checks if an expression is not null.
  1063.      *
  1064.      * @deprecated Use IS NOT NULL in SQL instead.
  1065.      *
  1066.      * @param string $expression The expression that should be compared to null.
  1067.      *
  1068.      * @return string The logical expression.
  1069.      */
  1070.     public function getIsNotNullExpression($expression)
  1071.     {
  1072.         Deprecation::trigger(
  1073.             'doctrine/dbal',
  1074.             'https://github.com/doctrine/dbal/pull/4724',
  1075.             'AbstractPlatform::getIsNotNullExpression() is deprecated. Use IS NOT NULL in SQL instead.',
  1076.         );
  1077.         return $expression ' IS NOT NULL';
  1078.     }
  1079.     /**
  1080.      * Returns the SQL that checks if an expression evaluates to a value between two values.
  1081.      *
  1082.      * The parameter $expression is checked if it is between $value1 and $value2.
  1083.      *
  1084.      * Note: There is a slight difference in the way BETWEEN works on some databases.
  1085.      * http://www.w3schools.com/sql/sql_between.asp. If you want complete database
  1086.      * independence you should avoid using between().
  1087.      *
  1088.      * @deprecated Use BETWEEN in SQL instead.
  1089.      *
  1090.      * @param string $expression The value to compare to.
  1091.      * @param string $value1     The lower value to compare with.
  1092.      * @param string $value2     The higher value to compare with.
  1093.      *
  1094.      * @return string The logical expression.
  1095.      */
  1096.     public function getBetweenExpression($expression$value1$value2)
  1097.     {
  1098.         Deprecation::trigger(
  1099.             'doctrine/dbal',
  1100.             'https://github.com/doctrine/dbal/pull/4724',
  1101.             'AbstractPlatform::getBetweenExpression() is deprecated. Use BETWEEN in SQL instead.',
  1102.         );
  1103.         return $expression ' BETWEEN ' $value1 ' AND ' $value2;
  1104.     }
  1105.     /**
  1106.      * Returns the SQL to get the arccosine of a value.
  1107.      *
  1108.      * @deprecated Use ACOS() in SQL instead.
  1109.      *
  1110.      * @param string $value
  1111.      *
  1112.      * @return string
  1113.      */
  1114.     public function getAcosExpression($value)
  1115.     {
  1116.         Deprecation::trigger(
  1117.             'doctrine/dbal',
  1118.             'https://github.com/doctrine/dbal/pull/4724',
  1119.             'AbstractPlatform::getAcosExpression() is deprecated. Use ACOS() in SQL instead.',
  1120.         );
  1121.         return 'ACOS(' $value ')';
  1122.     }
  1123.     /**
  1124.      * Returns the SQL to get the sine of a value.
  1125.      *
  1126.      * @deprecated Use SIN() in SQL instead.
  1127.      *
  1128.      * @param string $value
  1129.      *
  1130.      * @return string
  1131.      */
  1132.     public function getSinExpression($value)
  1133.     {
  1134.         Deprecation::trigger(
  1135.             'doctrine/dbal',
  1136.             'https://github.com/doctrine/dbal/pull/4724',
  1137.             'AbstractPlatform::getSinExpression() is deprecated. Use SIN() in SQL instead.',
  1138.         );
  1139.         return 'SIN(' $value ')';
  1140.     }
  1141.     /**
  1142.      * Returns the SQL to get the PI value.
  1143.      *
  1144.      * @deprecated Use PI() in SQL instead.
  1145.      *
  1146.      * @return string
  1147.      */
  1148.     public function getPiExpression()
  1149.     {
  1150.         Deprecation::trigger(
  1151.             'doctrine/dbal',
  1152.             'https://github.com/doctrine/dbal/pull/4724',
  1153.             'AbstractPlatform::getPiExpression() is deprecated. Use PI() in SQL instead.',
  1154.         );
  1155.         return 'PI()';
  1156.     }
  1157.     /**
  1158.      * Returns the SQL to get the cosine of a value.
  1159.      *
  1160.      * @deprecated Use COS() in SQL instead.
  1161.      *
  1162.      * @param string $value
  1163.      *
  1164.      * @return string
  1165.      */
  1166.     public function getCosExpression($value)
  1167.     {
  1168.         Deprecation::trigger(
  1169.             'doctrine/dbal',
  1170.             'https://github.com/doctrine/dbal/pull/4724',
  1171.             'AbstractPlatform::getCosExpression() is deprecated. Use COS() in SQL instead.',
  1172.         );
  1173.         return 'COS(' $value ')';
  1174.     }
  1175.     /**
  1176.      * Returns the SQL to calculate the difference in days between the two passed dates.
  1177.      *
  1178.      * Computes diff = date1 - date2.
  1179.      *
  1180.      * @param string $date1
  1181.      * @param string $date2
  1182.      *
  1183.      * @return string
  1184.      *
  1185.      * @throws Exception If not supported on this platform.
  1186.      */
  1187.     public function getDateDiffExpression($date1$date2)
  1188.     {
  1189.         throw Exception::notSupported(__METHOD__);
  1190.     }
  1191.     /**
  1192.      * Returns the SQL to add the number of given seconds to a date.
  1193.      *
  1194.      * @param string     $date
  1195.      * @param int|string $seconds
  1196.      *
  1197.      * @return string
  1198.      *
  1199.      * @throws Exception If not supported on this platform.
  1200.      */
  1201.     public function getDateAddSecondsExpression($date$seconds)
  1202.     {
  1203.         if (is_int($seconds)) {
  1204.             Deprecation::trigger(
  1205.                 'doctrine/dbal',
  1206.                 'https://github.com/doctrine/dbal/pull/3498',
  1207.                 'Passing $seconds as an integer is deprecated. Pass it as a numeric string instead.',
  1208.             );
  1209.         }
  1210.         return $this->getDateArithmeticIntervalExpression($date'+'$secondsDateIntervalUnit::SECOND);
  1211.     }
  1212.     /**
  1213.      * Returns the SQL to subtract the number of given seconds from a date.
  1214.      *
  1215.      * @param string     $date
  1216.      * @param int|string $seconds
  1217.      *
  1218.      * @return string
  1219.      *
  1220.      * @throws Exception If not supported on this platform.
  1221.      */
  1222.     public function getDateSubSecondsExpression($date$seconds)
  1223.     {
  1224.         if (is_int($seconds)) {
  1225.             Deprecation::trigger(
  1226.                 'doctrine/dbal',
  1227.                 'https://github.com/doctrine/dbal/pull/3498',
  1228.                 'Passing $seconds as an integer is deprecated. Pass it as a numeric string instead.',
  1229.             );
  1230.         }
  1231.         return $this->getDateArithmeticIntervalExpression($date'-'$secondsDateIntervalUnit::SECOND);
  1232.     }
  1233.     /**
  1234.      * Returns the SQL to add the number of given minutes to a date.
  1235.      *
  1236.      * @param string     $date
  1237.      * @param int|string $minutes
  1238.      *
  1239.      * @return string
  1240.      *
  1241.      * @throws Exception If not supported on this platform.
  1242.      */
  1243.     public function getDateAddMinutesExpression($date$minutes)
  1244.     {
  1245.         if (is_int($minutes)) {
  1246.             Deprecation::trigger(
  1247.                 'doctrine/dbal',
  1248.                 'https://github.com/doctrine/dbal/pull/3498',
  1249.                 'Passing $minutes as an integer is deprecated. Pass it as a numeric string instead.',
  1250.             );
  1251.         }
  1252.         return $this->getDateArithmeticIntervalExpression($date'+'$minutesDateIntervalUnit::MINUTE);
  1253.     }
  1254.     /**
  1255.      * Returns the SQL to subtract the number of given minutes from a date.
  1256.      *
  1257.      * @param string     $date
  1258.      * @param int|string $minutes
  1259.      *
  1260.      * @return string
  1261.      *
  1262.      * @throws Exception If not supported on this platform.
  1263.      */
  1264.     public function getDateSubMinutesExpression($date$minutes)
  1265.     {
  1266.         if (is_int($minutes)) {
  1267.             Deprecation::trigger(
  1268.                 'doctrine/dbal',
  1269.                 'https://github.com/doctrine/dbal/pull/3498',
  1270.                 'Passing $minutes as an integer is deprecated. Pass it as a numeric string instead.',
  1271.             );
  1272.         }
  1273.         return $this->getDateArithmeticIntervalExpression($date'-'$minutesDateIntervalUnit::MINUTE);
  1274.     }
  1275.     /**
  1276.      * Returns the SQL to add the number of given hours to a date.
  1277.      *
  1278.      * @param string     $date
  1279.      * @param int|string $hours
  1280.      *
  1281.      * @return string
  1282.      *
  1283.      * @throws Exception If not supported on this platform.
  1284.      */
  1285.     public function getDateAddHourExpression($date$hours)
  1286.     {
  1287.         if (is_int($hours)) {
  1288.             Deprecation::trigger(
  1289.                 'doctrine/dbal',
  1290.                 'https://github.com/doctrine/dbal/pull/3498',
  1291.                 'Passing $hours as an integer is deprecated. Pass it as a numeric string instead.',
  1292.             );
  1293.         }
  1294.         return $this->getDateArithmeticIntervalExpression($date'+'$hoursDateIntervalUnit::HOUR);
  1295.     }
  1296.     /**
  1297.      * Returns the SQL to subtract the number of given hours to a date.
  1298.      *
  1299.      * @param string     $date
  1300.      * @param int|string $hours
  1301.      *
  1302.      * @return string
  1303.      *
  1304.      * @throws Exception If not supported on this platform.
  1305.      */
  1306.     public function getDateSubHourExpression($date$hours)
  1307.     {
  1308.         if (is_int($hours)) {
  1309.             Deprecation::trigger(
  1310.                 'doctrine/dbal',
  1311.                 'https://github.com/doctrine/dbal/pull/3498',
  1312.                 'Passing $hours as an integer is deprecated. Pass it as a numeric string instead.',
  1313.             );
  1314.         }
  1315.         return $this->getDateArithmeticIntervalExpression($date'-'$hoursDateIntervalUnit::HOUR);
  1316.     }
  1317.     /**
  1318.      * Returns the SQL to add the number of given days to a date.
  1319.      *
  1320.      * @param string     $date
  1321.      * @param int|string $days
  1322.      *
  1323.      * @return string
  1324.      *
  1325.      * @throws Exception If not supported on this platform.
  1326.      */
  1327.     public function getDateAddDaysExpression($date$days)
  1328.     {
  1329.         if (is_int($days)) {
  1330.             Deprecation::trigger(
  1331.                 'doctrine/dbal',
  1332.                 'https://github.com/doctrine/dbal/pull/3498',
  1333.                 'Passing $days as an integer is deprecated. Pass it as a numeric string instead.',
  1334.             );
  1335.         }
  1336.         return $this->getDateArithmeticIntervalExpression($date'+'$daysDateIntervalUnit::DAY);
  1337.     }
  1338.     /**
  1339.      * Returns the SQL to subtract the number of given days to a date.
  1340.      *
  1341.      * @param string     $date
  1342.      * @param int|string $days
  1343.      *
  1344.      * @return string
  1345.      *
  1346.      * @throws Exception If not supported on this platform.
  1347.      */
  1348.     public function getDateSubDaysExpression($date$days)
  1349.     {
  1350.         if (is_int($days)) {
  1351.             Deprecation::trigger(
  1352.                 'doctrine/dbal',
  1353.                 'https://github.com/doctrine/dbal/pull/3498',
  1354.                 'Passing $days as an integer is deprecated. Pass it as a numeric string instead.',
  1355.             );
  1356.         }
  1357.         return $this->getDateArithmeticIntervalExpression($date'-'$daysDateIntervalUnit::DAY);
  1358.     }
  1359.     /**
  1360.      * Returns the SQL to add the number of given weeks to a date.
  1361.      *
  1362.      * @param string     $date
  1363.      * @param int|string $weeks
  1364.      *
  1365.      * @return string
  1366.      *
  1367.      * @throws Exception If not supported on this platform.
  1368.      */
  1369.     public function getDateAddWeeksExpression($date$weeks)
  1370.     {
  1371.         if (is_int($weeks)) {
  1372.             Deprecation::trigger(
  1373.                 'doctrine/dbal',
  1374.                 'https://github.com/doctrine/dbal/pull/3498',
  1375.                 'Passing $weeks as an integer is deprecated. Pass it as a numeric string instead.',
  1376.             );
  1377.         }
  1378.         return $this->getDateArithmeticIntervalExpression($date'+'$weeksDateIntervalUnit::WEEK);
  1379.     }
  1380.     /**
  1381.      * Returns the SQL to subtract the number of given weeks from a date.
  1382.      *
  1383.      * @param string     $date
  1384.      * @param int|string $weeks
  1385.      *
  1386.      * @return string
  1387.      *
  1388.      * @throws Exception If not supported on this platform.
  1389.      */
  1390.     public function getDateSubWeeksExpression($date$weeks)
  1391.     {
  1392.         if (is_int($weeks)) {
  1393.             Deprecation::trigger(
  1394.                 'doctrine/dbal',
  1395.                 'https://github.com/doctrine/dbal/pull/3498',
  1396.                 'Passing $weeks as an integer is deprecated. Pass it as a numeric string instead.',
  1397.             );
  1398.         }
  1399.         return $this->getDateArithmeticIntervalExpression($date'-'$weeksDateIntervalUnit::WEEK);
  1400.     }
  1401.     /**
  1402.      * Returns the SQL to add the number of given months to a date.
  1403.      *
  1404.      * @param string     $date
  1405.      * @param int|string $months
  1406.      *
  1407.      * @return string
  1408.      *
  1409.      * @throws Exception If not supported on this platform.
  1410.      */
  1411.     public function getDateAddMonthExpression($date$months)
  1412.     {
  1413.         if (is_int($months)) {
  1414.             Deprecation::trigger(
  1415.                 'doctrine/dbal',
  1416.                 'https://github.com/doctrine/dbal/pull/3498',
  1417.                 'Passing $months as an integer is deprecated. Pass it as a numeric string instead.',
  1418.             );
  1419.         }
  1420.         return $this->getDateArithmeticIntervalExpression($date'+'$monthsDateIntervalUnit::MONTH);
  1421.     }
  1422.     /**
  1423.      * Returns the SQL to subtract the number of given months to a date.
  1424.      *
  1425.      * @param string     $date
  1426.      * @param int|string $months
  1427.      *
  1428.      * @return string
  1429.      *
  1430.      * @throws Exception If not supported on this platform.
  1431.      */
  1432.     public function getDateSubMonthExpression($date$months)
  1433.     {
  1434.         if (is_int($months)) {
  1435.             Deprecation::trigger(
  1436.                 'doctrine/dbal',
  1437.                 'https://github.com/doctrine/dbal/pull/3498',
  1438.                 'Passing $months as an integer is deprecated. Pass it as a numeric string instead.',
  1439.             );
  1440.         }
  1441.         return $this->getDateArithmeticIntervalExpression($date'-'$monthsDateIntervalUnit::MONTH);
  1442.     }
  1443.     /**
  1444.      * Returns the SQL to add the number of given quarters to a date.
  1445.      *
  1446.      * @param string     $date
  1447.      * @param int|string $quarters
  1448.      *
  1449.      * @return string
  1450.      *
  1451.      * @throws Exception If not supported on this platform.
  1452.      */
  1453.     public function getDateAddQuartersExpression($date$quarters)
  1454.     {
  1455.         if (is_int($quarters)) {
  1456.             Deprecation::trigger(
  1457.                 'doctrine/dbal',
  1458.                 'https://github.com/doctrine/dbal/pull/3498',
  1459.                 'Passing $quarters as an integer is deprecated. Pass it as a numeric string instead.',
  1460.             );
  1461.         }
  1462.         return $this->getDateArithmeticIntervalExpression($date'+'$quartersDateIntervalUnit::QUARTER);
  1463.     }
  1464.     /**
  1465.      * Returns the SQL to subtract the number of given quarters from a date.
  1466.      *
  1467.      * @param string     $date
  1468.      * @param int|string $quarters
  1469.      *
  1470.      * @return string
  1471.      *
  1472.      * @throws Exception If not supported on this platform.
  1473.      */
  1474.     public function getDateSubQuartersExpression($date$quarters)
  1475.     {
  1476.         if (is_int($quarters)) {
  1477.             Deprecation::trigger(
  1478.                 'doctrine/dbal',
  1479.                 'https://github.com/doctrine/dbal/pull/3498',
  1480.                 'Passing $quarters as an integer is deprecated. Pass it as a numeric string instead.',
  1481.             );
  1482.         }
  1483.         return $this->getDateArithmeticIntervalExpression($date'-'$quartersDateIntervalUnit::QUARTER);
  1484.     }
  1485.     /**
  1486.      * Returns the SQL to add the number of given years to a date.
  1487.      *
  1488.      * @param string     $date
  1489.      * @param int|string $years
  1490.      *
  1491.      * @return string
  1492.      *
  1493.      * @throws Exception If not supported on this platform.
  1494.      */
  1495.     public function getDateAddYearsExpression($date$years)
  1496.     {
  1497.         if (is_int($years)) {
  1498.             Deprecation::trigger(
  1499.                 'doctrine/dbal',
  1500.                 'https://github.com/doctrine/dbal/pull/3498',
  1501.                 'Passing $years as an integer is deprecated. Pass it as a numeric string instead.',
  1502.             );
  1503.         }
  1504.         return $this->getDateArithmeticIntervalExpression($date'+'$yearsDateIntervalUnit::YEAR);
  1505.     }
  1506.     /**
  1507.      * Returns the SQL to subtract the number of given years from a date.
  1508.      *
  1509.      * @param string     $date
  1510.      * @param int|string $years
  1511.      *
  1512.      * @return string
  1513.      *
  1514.      * @throws Exception If not supported on this platform.
  1515.      */
  1516.     public function getDateSubYearsExpression($date$years)
  1517.     {
  1518.         if (is_int($years)) {
  1519.             Deprecation::trigger(
  1520.                 'doctrine/dbal',
  1521.                 'https://github.com/doctrine/dbal/pull/3498',
  1522.                 'Passing $years as an integer is deprecated. Pass it as a numeric string instead.',
  1523.             );
  1524.         }
  1525.         return $this->getDateArithmeticIntervalExpression($date'-'$yearsDateIntervalUnit::YEAR);
  1526.     }
  1527.     /**
  1528.      * Returns the SQL for a date arithmetic expression.
  1529.      *
  1530.      * @param string     $date     The column or literal representing a date
  1531.      *                                     to perform the arithmetic operation on.
  1532.      * @param string     $operator The arithmetic operator (+ or -).
  1533.      * @param int|string $interval The interval that shall be calculated into the date.
  1534.      * @param string     $unit     The unit of the interval that shall be calculated into the date.
  1535.      *                                     One of the {@see DateIntervalUnit} constants.
  1536.      *
  1537.      * @return string
  1538.      *
  1539.      * @throws Exception If not supported on this platform.
  1540.      */
  1541.     protected function getDateArithmeticIntervalExpression($date$operator$interval$unit)
  1542.     {
  1543.         throw Exception::notSupported(__METHOD__);
  1544.     }
  1545.     /**
  1546.      * Generates the SQL expression which represents the given date interval multiplied by a number
  1547.      *
  1548.      * @param string $interval   SQL expression describing the interval value
  1549.      * @param int    $multiplier Interval multiplier
  1550.      */
  1551.     protected function multiplyInterval(string $intervalint $multiplier): string
  1552.     {
  1553.         return sprintf('(%s * %d)'$interval$multiplier);
  1554.     }
  1555.     /**
  1556.      * Returns the SQL bit AND comparison expression.
  1557.      *
  1558.      * @param string $value1
  1559.      * @param string $value2
  1560.      *
  1561.      * @return string
  1562.      */
  1563.     public function getBitAndComparisonExpression($value1$value2)
  1564.     {
  1565.         return '(' $value1 ' & ' $value2 ')';
  1566.     }
  1567.     /**
  1568.      * Returns the SQL bit OR comparison expression.
  1569.      *
  1570.      * @param string $value1
  1571.      * @param string $value2
  1572.      *
  1573.      * @return string
  1574.      */
  1575.     public function getBitOrComparisonExpression($value1$value2)
  1576.     {
  1577.         return '(' $value1 ' | ' $value2 ')';
  1578.     }
  1579.     /**
  1580.      * Returns the SQL expression which represents the currently selected database.
  1581.      */
  1582.     abstract public function getCurrentDatabaseExpression(): string;
  1583.     /**
  1584.      * Returns the FOR UPDATE expression.
  1585.      *
  1586.      * @deprecated This API is not portable. Use {@link QueryBuilder::forUpdate()}` instead.
  1587.      *
  1588.      * @return string
  1589.      */
  1590.     public function getForUpdateSQL()
  1591.     {
  1592.         Deprecation::triggerIfCalledFromOutside(
  1593.             'doctrine/dbal',
  1594.             'https://github.com/doctrine/dbal/pull/6191',
  1595.             '%s is deprecated as non-portable.',
  1596.             __METHOD__,
  1597.         );
  1598.         return 'FOR UPDATE';
  1599.     }
  1600.     /**
  1601.      * Honors that some SQL vendors such as MsSql use table hints for locking instead of the
  1602.      * ANSI SQL FOR UPDATE specification.
  1603.      *
  1604.      * @param string $fromClause The FROM clause to append the hint for the given lock mode to
  1605.      * @param int    $lockMode   One of the Doctrine\DBAL\LockMode::* constants
  1606.      * @psalm-param LockMode::* $lockMode
  1607.      */
  1608.     public function appendLockHint(string $fromClauseint $lockMode): string
  1609.     {
  1610.         switch ($lockMode) {
  1611.             case LockMode::NONE:
  1612.             case LockMode::OPTIMISTIC:
  1613.             case LockMode::PESSIMISTIC_READ:
  1614.             case LockMode::PESSIMISTIC_WRITE:
  1615.                 return $fromClause;
  1616.             default:
  1617.                 throw InvalidLockMode::fromLockMode($lockMode);
  1618.         }
  1619.     }
  1620.     /**
  1621.      * Returns the SQL snippet to append to any SELECT statement which locks rows in shared read lock.
  1622.      *
  1623.      * This defaults to the ANSI SQL "FOR UPDATE", which is an exclusive lock (Write). Some database
  1624.      * vendors allow to lighten this constraint up to be a real read lock.
  1625.      *
  1626.      * @deprecated This API is not portable.
  1627.      *
  1628.      * @return string
  1629.      */
  1630.     public function getReadLockSQL()
  1631.     {
  1632.         Deprecation::trigger(
  1633.             'doctrine/dbal',
  1634.             'https://github.com/doctrine/dbal/pull/6191',
  1635.             '%s is deprecated as non-portable.',
  1636.             __METHOD__,
  1637.         );
  1638.         return $this->getForUpdateSQL();
  1639.     }
  1640.     /**
  1641.      * Returns the SQL snippet to append to any SELECT statement which obtains an exclusive lock on the rows.
  1642.      *
  1643.      * The semantics of this lock mode should equal the SELECT .. FOR UPDATE of the ANSI SQL standard.
  1644.      *
  1645.      * @deprecated This API is not portable.
  1646.      *
  1647.      * @return string
  1648.      */
  1649.     public function getWriteLockSQL()
  1650.     {
  1651.         Deprecation::trigger(
  1652.             'doctrine/dbal',
  1653.             'https://github.com/doctrine/dbal/pull/6191',
  1654.             '%s is deprecated as non-portable.',
  1655.             __METHOD__,
  1656.         );
  1657.         return $this->getForUpdateSQL();
  1658.     }
  1659.     /**
  1660.      * Returns the SQL snippet to drop an existing table.
  1661.      *
  1662.      * @param Table|string $table
  1663.      *
  1664.      * @return string
  1665.      *
  1666.      * @throws InvalidArgumentException
  1667.      */
  1668.     public function getDropTableSQL($table)
  1669.     {
  1670.         $tableArg $table;
  1671.         if ($table instanceof Table) {
  1672.             Deprecation::trigger(
  1673.                 'doctrine/dbal',
  1674.                 'https://github.com/doctrine/dbal/issues/4798',
  1675.                 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.',
  1676.                 __METHOD__,
  1677.             );
  1678.             $table $table->getQuotedName($this);
  1679.         }
  1680.         if (! is_string($table)) {
  1681.             throw new InvalidArgumentException(
  1682.                 __METHOD__ '() expects $table parameter to be string or ' Table::class . '.',
  1683.             );
  1684.         }
  1685.         if ($this->_eventManager !== null && $this->_eventManager->hasListeners(Events::onSchemaDropTable)) {
  1686.             Deprecation::trigger(
  1687.                 'doctrine/dbal',
  1688.                 'https://github.com/doctrine/dbal/issues/5784',
  1689.                 'Subscribing to %s events is deprecated.',
  1690.                 Events::onSchemaDropTable,
  1691.             );
  1692.             $eventArgs = new SchemaDropTableEventArgs($tableArg$this);
  1693.             $this->_eventManager->dispatchEvent(Events::onSchemaDropTable$eventArgs);
  1694.             if ($eventArgs->isDefaultPrevented()) {
  1695.                 $sql $eventArgs->getSql();
  1696.                 if ($sql === null) {
  1697.                     throw new UnexpectedValueException('Default implementation of DROP TABLE was overridden with NULL');
  1698.                 }
  1699.                 return $sql;
  1700.             }
  1701.         }
  1702.         return 'DROP TABLE ' $table;
  1703.     }
  1704.     /**
  1705.      * Returns the SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction.
  1706.      *
  1707.      * @param Table|string $table
  1708.      *
  1709.      * @return string
  1710.      */
  1711.     public function getDropTemporaryTableSQL($table)
  1712.     {
  1713.         if ($table instanceof Table) {
  1714.             Deprecation::trigger(
  1715.                 'doctrine/dbal',
  1716.                 'https://github.com/doctrine/dbal/issues/4798',
  1717.                 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.',
  1718.                 __METHOD__,
  1719.             );
  1720.             $table $table->getQuotedName($this);
  1721.         }
  1722.         return $this->getDropTableSQL($table);
  1723.     }
  1724.     /**
  1725.      * Returns the SQL to drop an index from a table.
  1726.      *
  1727.      * @param Index|string      $index
  1728.      * @param Table|string|null $table
  1729.      *
  1730.      * @return string
  1731.      *
  1732.      * @throws InvalidArgumentException
  1733.      */
  1734.     public function getDropIndexSQL($index$table null)
  1735.     {
  1736.         if ($index instanceof Index) {
  1737.             Deprecation::trigger(
  1738.                 'doctrine/dbal',
  1739.                 'https://github.com/doctrine/dbal/issues/4798',
  1740.                 'Passing $index as an Index object to %s is deprecated. Pass it as a quoted name instead.',
  1741.                 __METHOD__,
  1742.             );
  1743.             $index $index->getQuotedName($this);
  1744.         } elseif (! is_string($index)) {
  1745.             throw new InvalidArgumentException(
  1746.                 __METHOD__ '() expects $index parameter to be string or ' Index::class . '.',
  1747.             );
  1748.         }
  1749.         return 'DROP INDEX ' $index;
  1750.     }
  1751.     /**
  1752.      * Returns the SQL to drop a constraint.
  1753.      *
  1754.      * @internal The method should be only used from within the {@see AbstractPlatform} class hierarchy.
  1755.      *
  1756.      * @param Constraint|string $constraint
  1757.      * @param Table|string      $table
  1758.      *
  1759.      * @return string
  1760.      */
  1761.     public function getDropConstraintSQL($constraint$table)
  1762.     {
  1763.         if ($constraint instanceof Constraint) {
  1764.             Deprecation::trigger(
  1765.                 'doctrine/dbal',
  1766.                 'https://github.com/doctrine/dbal/issues/4798',
  1767.                 'Passing $constraint as a Constraint object to %s is deprecated. Pass it as a quoted name instead.',
  1768.                 __METHOD__,
  1769.             );
  1770.         } else {
  1771.             $constraint = new Identifier($constraint);
  1772.         }
  1773.         if ($table instanceof Table) {
  1774.             Deprecation::trigger(
  1775.                 'doctrine/dbal',
  1776.                 'https://github.com/doctrine/dbal/issues/4798',
  1777.                 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.',
  1778.                 __METHOD__,
  1779.             );
  1780.         } else {
  1781.             $table = new Identifier($table);
  1782.         }
  1783.         $constraint $constraint->getQuotedName($this);
  1784.         $table      $table->getQuotedName($this);
  1785.         return 'ALTER TABLE ' $table ' DROP CONSTRAINT ' $constraint;
  1786.     }
  1787.     /**
  1788.      * Returns the SQL to drop a foreign key.
  1789.      *
  1790.      * @param ForeignKeyConstraint|string $foreignKey
  1791.      * @param Table|string                $table
  1792.      *
  1793.      * @return string
  1794.      */
  1795.     public function getDropForeignKeySQL($foreignKey$table)
  1796.     {
  1797.         if ($foreignKey instanceof ForeignKeyConstraint) {
  1798.             Deprecation::trigger(
  1799.                 'doctrine/dbal',
  1800.                 'https://github.com/doctrine/dbal/issues/4798',
  1801.                 'Passing $foreignKey as a ForeignKeyConstraint object to %s is deprecated.'
  1802.                     ' Pass it as a quoted name instead.',
  1803.                 __METHOD__,
  1804.             );
  1805.         } else {
  1806.             $foreignKey = new Identifier($foreignKey);
  1807.         }
  1808.         if ($table instanceof Table) {
  1809.             Deprecation::trigger(
  1810.                 'doctrine/dbal',
  1811.                 'https://github.com/doctrine/dbal/issues/4798',
  1812.                 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.',
  1813.                 __METHOD__,
  1814.             );
  1815.         } else {
  1816.             $table = new Identifier($table);
  1817.         }
  1818.         $foreignKey $foreignKey->getQuotedName($this);
  1819.         $table      $table->getQuotedName($this);
  1820.         return 'ALTER TABLE ' $table ' DROP FOREIGN KEY ' $foreignKey;
  1821.     }
  1822.     /**
  1823.      * Returns the SQL to drop a unique constraint.
  1824.      */
  1825.     public function getDropUniqueConstraintSQL(string $namestring $tableName): string
  1826.     {
  1827.         return $this->getDropConstraintSQL($name$tableName);
  1828.     }
  1829.     /**
  1830.      * Returns the SQL statement(s) to create a table with the specified name, columns and constraints
  1831.      * on this platform.
  1832.      *
  1833.      * @param int $createFlags
  1834.      * @psalm-param int-mask-of<self::CREATE_*> $createFlags
  1835.      *
  1836.      * @return list<string> The list of SQL statements.
  1837.      *
  1838.      * @throws Exception
  1839.      * @throws InvalidArgumentException
  1840.      */
  1841.     public function getCreateTableSQL(Table $table$createFlags self::CREATE_INDEXES)
  1842.     {
  1843.         if (! is_int($createFlags)) {
  1844.             throw new InvalidArgumentException(
  1845.                 'Second argument of AbstractPlatform::getCreateTableSQL() has to be integer.',
  1846.             );
  1847.         }
  1848.         if (($createFlags self::CREATE_INDEXES) === 0) {
  1849.             Deprecation::trigger(
  1850.                 'doctrine/dbal',
  1851.                 'https://github.com/doctrine/dbal/pull/5416',
  1852.                 'Unsetting the CREATE_INDEXES flag in AbstractPlatform::getCreateTableSQL() is deprecated.',
  1853.             );
  1854.         }
  1855.         if (($createFlags self::CREATE_FOREIGNKEYS) === 0) {
  1856.             Deprecation::trigger(
  1857.                 'doctrine/dbal',
  1858.                 'https://github.com/doctrine/dbal/pull/5416',
  1859.                 'Not setting the CREATE_FOREIGNKEYS flag in AbstractPlatform::getCreateTableSQL()'
  1860.                     ' is deprecated. In order to build the statements that create multiple tables'
  1861.                     ' referencing each other via foreign keys, use AbstractPlatform::getCreateTablesSQL().',
  1862.             );
  1863.         }
  1864.         return $this->buildCreateTableSQL(
  1865.             $table,
  1866.             ($createFlags self::CREATE_INDEXES) > 0,
  1867.             ($createFlags self::CREATE_FOREIGNKEYS) > 0,
  1868.         );
  1869.     }
  1870.     public function createSelectSQLBuilder(): SelectSQLBuilder
  1871.     {
  1872.         return new DefaultSelectSQLBuilder($this'FOR UPDATE''SKIP LOCKED');
  1873.     }
  1874.     /**
  1875.      * @internal
  1876.      *
  1877.      * @return list<string>
  1878.      *
  1879.      * @throws Exception
  1880.      */
  1881.     final protected function getCreateTableWithoutForeignKeysSQL(Table $table): array
  1882.     {
  1883.         return $this->buildCreateTableSQL($tabletruefalse);
  1884.     }
  1885.     /**
  1886.      * @return list<string>
  1887.      *
  1888.      * @throws Exception
  1889.      */
  1890.     private function buildCreateTableSQL(Table $tablebool $createIndexesbool $createForeignKeys): array
  1891.     {
  1892.         if (count($table->getColumns()) === 0) {
  1893.             throw Exception::noColumnsSpecifiedForTable($table->getName());
  1894.         }
  1895.         $tableName                    $table->getQuotedName($this);
  1896.         $options                      $table->getOptions();
  1897.         $options['uniqueConstraints'] = [];
  1898.         $options['indexes']           = [];
  1899.         $options['primary']           = [];
  1900.         if ($createIndexes) {
  1901.             foreach ($table->getIndexes() as $index) {
  1902.                 if (! $index->isPrimary()) {
  1903.                     $options['indexes'][$index->getQuotedName($this)] = $index;
  1904.                     continue;
  1905.                 }
  1906.                 $options['primary']       = $index->getQuotedColumns($this);
  1907.                 $options['primary_index'] = $index;
  1908.             }
  1909.             foreach ($table->getUniqueConstraints() as $uniqueConstraint) {
  1910.                 $options['uniqueConstraints'][$uniqueConstraint->getQuotedName($this)] = $uniqueConstraint;
  1911.             }
  1912.         }
  1913.         if ($createForeignKeys) {
  1914.             $options['foreignKeys'] = [];
  1915.             foreach ($table->getForeignKeys() as $fkConstraint) {
  1916.                 $options['foreignKeys'][] = $fkConstraint;
  1917.             }
  1918.         }
  1919.         $columnSql = [];
  1920.         $columns   = [];
  1921.         foreach ($table->getColumns() as $column) {
  1922.             if (
  1923.                 $this->_eventManager !== null
  1924.                 && $this->_eventManager->hasListeners(Events::onSchemaCreateTableColumn)
  1925.             ) {
  1926.                 Deprecation::trigger(
  1927.                     'doctrine/dbal',
  1928.                     'https://github.com/doctrine/dbal/issues/5784',
  1929.                     'Subscribing to %s events is deprecated.',
  1930.                     Events::onSchemaCreateTableColumn,
  1931.                 );
  1932.                 $eventArgs = new SchemaCreateTableColumnEventArgs($column$table$this);
  1933.                 $this->_eventManager->dispatchEvent(Events::onSchemaCreateTableColumn$eventArgs);
  1934.                 $columnSql array_merge($columnSql$eventArgs->getSql());
  1935.                 if ($eventArgs->isDefaultPrevented()) {
  1936.                     continue;
  1937.                 }
  1938.             }
  1939.             $columnData $this->columnToArray($column);
  1940.             if (in_array($column->getName(), $options['primary'], true)) {
  1941.                 $columnData['primary'] = true;
  1942.             }
  1943.             $columns[$columnData['name']] = $columnData;
  1944.         }
  1945.         if ($this->_eventManager !== null && $this->_eventManager->hasListeners(Events::onSchemaCreateTable)) {
  1946.             Deprecation::trigger(
  1947.                 'doctrine/dbal',
  1948.                 'https://github.com/doctrine/dbal/issues/5784',
  1949.                 'Subscribing to %s events is deprecated.',
  1950.                 Events::onSchemaCreateTable,
  1951.             );
  1952.             $eventArgs = new SchemaCreateTableEventArgs($table$columns$options$this);
  1953.             $this->_eventManager->dispatchEvent(Events::onSchemaCreateTable$eventArgs);
  1954.             if ($eventArgs->isDefaultPrevented()) {
  1955.                 return array_merge($eventArgs->getSql(), $columnSql);
  1956.             }
  1957.         }
  1958.         $sql $this->_getCreateTableSQL($tableName$columns$options);
  1959.         if ($this->supportsCommentOnStatement()) {
  1960.             if ($table->hasOption('comment')) {
  1961.                 $sql[] = $this->getCommentOnTableSQL($tableName$table->getOption('comment'));
  1962.             }
  1963.             foreach ($table->getColumns() as $column) {
  1964.                 $comment $this->getColumnComment($column);
  1965.                 if ($comment === null || $comment === '') {
  1966.                     continue;
  1967.                 }
  1968.                 $sql[] = $this->getCommentOnColumnSQL($tableName$column->getQuotedName($this), $comment);
  1969.             }
  1970.         }
  1971.         return array_merge($sql$columnSql);
  1972.     }
  1973.     /**
  1974.      * @param list<Table> $tables
  1975.      *
  1976.      * @return list<string>
  1977.      *
  1978.      * @throws Exception
  1979.      */
  1980.     public function getCreateTablesSQL(array $tables): array
  1981.     {
  1982.         $sql = [];
  1983.         foreach ($tables as $table) {
  1984.             $sql array_merge($sql$this->getCreateTableWithoutForeignKeysSQL($table));
  1985.         }
  1986.         foreach ($tables as $table) {
  1987.             foreach ($table->getForeignKeys() as $foreignKey) {
  1988.                 $sql[] = $this->getCreateForeignKeySQL(
  1989.                     $foreignKey,
  1990.                     $table->getQuotedName($this),
  1991.                 );
  1992.             }
  1993.         }
  1994.         return $sql;
  1995.     }
  1996.     /**
  1997.      * @param list<Table> $tables
  1998.      *
  1999.      * @return list<string>
  2000.      */
  2001.     public function getDropTablesSQL(array $tables): array
  2002.     {
  2003.         $sql = [];
  2004.         foreach ($tables as $table) {
  2005.             foreach ($table->getForeignKeys() as $foreignKey) {
  2006.                 $sql[] = $this->getDropForeignKeySQL(
  2007.                     $foreignKey->getQuotedName($this),
  2008.                     $table->getQuotedName($this),
  2009.                 );
  2010.             }
  2011.         }
  2012.         foreach ($tables as $table) {
  2013.             $sql[] = $this->getDropTableSQL($table->getQuotedName($this));
  2014.         }
  2015.         return $sql;
  2016.     }
  2017.     protected function getCommentOnTableSQL(string $tableName, ?string $comment): string
  2018.     {
  2019.         $tableName = new Identifier($tableName);
  2020.         return sprintf(
  2021.             'COMMENT ON TABLE %s IS %s',
  2022.             $tableName->getQuotedName($this),
  2023.             $this->quoteStringLiteral((string) $comment),
  2024.         );
  2025.     }
  2026.     /**
  2027.      * @param string      $tableName
  2028.      * @param string      $columnName
  2029.      * @param string|null $comment
  2030.      *
  2031.      * @return string
  2032.      */
  2033.     public function getCommentOnColumnSQL($tableName$columnName$comment)
  2034.     {
  2035.         $tableName  = new Identifier($tableName);
  2036.         $columnName = new Identifier($columnName);
  2037.         return sprintf(
  2038.             'COMMENT ON COLUMN %s.%s IS %s',
  2039.             $tableName->getQuotedName($this),
  2040.             $columnName->getQuotedName($this),
  2041.             $this->quoteStringLiteral((string) $comment),
  2042.         );
  2043.     }
  2044.     /**
  2045.      * Returns the SQL to create inline comment on a column.
  2046.      *
  2047.      * @param string $comment
  2048.      *
  2049.      * @return string
  2050.      *
  2051.      * @throws Exception If not supported on this platform.
  2052.      */
  2053.     public function getInlineColumnCommentSQL($comment)
  2054.     {
  2055.         if (! $this->supportsInlineColumnComments()) {
  2056.             throw Exception::notSupported(__METHOD__);
  2057.         }
  2058.         return 'COMMENT ' $this->quoteStringLiteral($comment);
  2059.     }
  2060.     /**
  2061.      * Returns the SQL used to create a table.
  2062.      *
  2063.      * @param string    $name
  2064.      * @param mixed[][] $columns
  2065.      * @param mixed[]   $options
  2066.      *
  2067.      * @return string[]
  2068.      */
  2069.     protected function _getCreateTableSQL($name, array $columns, array $options = [])
  2070.     {
  2071.         $columnListSql $this->getColumnDeclarationListSQL($columns);
  2072.         if (isset($options['uniqueConstraints']) && ! empty($options['uniqueConstraints'])) {
  2073.             foreach ($options['uniqueConstraints'] as $index => $definition) {
  2074.                 $columnListSql .= ', ' $this->getUniqueConstraintDeclarationSQL($index$definition);
  2075.             }
  2076.         }
  2077.         if (isset($options['primary']) && ! empty($options['primary'])) {
  2078.             $columnListSql .= ', PRIMARY KEY(' implode(', 'array_unique(array_values($options['primary']))) . ')';
  2079.         }
  2080.         if (isset($options['indexes']) && ! empty($options['indexes'])) {
  2081.             foreach ($options['indexes'] as $index => $definition) {
  2082.                 $columnListSql .= ', ' $this->getIndexDeclarationSQL($index$definition);
  2083.             }
  2084.         }
  2085.         $query 'CREATE TABLE ' $name ' (' $columnListSql;
  2086.         $check $this->getCheckDeclarationSQL($columns);
  2087.         if (! empty($check)) {
  2088.             $query .= ', ' $check;
  2089.         }
  2090.         $query .= ')';
  2091.         $sql = [$query];
  2092.         if (isset($options['foreignKeys'])) {
  2093.             foreach ($options['foreignKeys'] as $definition) {
  2094.                 $sql[] = $this->getCreateForeignKeySQL($definition$name);
  2095.             }
  2096.         }
  2097.         return $sql;
  2098.     }
  2099.     /** @return string */
  2100.     public function getCreateTemporaryTableSnippetSQL()
  2101.     {
  2102.         return 'CREATE TEMPORARY TABLE';
  2103.     }
  2104.     /**
  2105.      * Generates SQL statements that can be used to apply the diff.
  2106.      *
  2107.      * @return list<string>
  2108.      */
  2109.     public function getAlterSchemaSQL(SchemaDiff $diff): array
  2110.     {
  2111.         return $diff->toSql($this);
  2112.     }
  2113.     /**
  2114.      * Returns the SQL to create a sequence on this platform.
  2115.      *
  2116.      * @return string
  2117.      *
  2118.      * @throws Exception If not supported on this platform.
  2119.      */
  2120.     public function getCreateSequenceSQL(Sequence $sequence)
  2121.     {
  2122.         throw Exception::notSupported(__METHOD__);
  2123.     }
  2124.     /**
  2125.      * Returns the SQL to change a sequence on this platform.
  2126.      *
  2127.      * @return string
  2128.      *
  2129.      * @throws Exception If not supported on this platform.
  2130.      */
  2131.     public function getAlterSequenceSQL(Sequence $sequence)
  2132.     {
  2133.         throw Exception::notSupported(__METHOD__);
  2134.     }
  2135.     /**
  2136.      * Returns the SQL snippet to drop an existing sequence.
  2137.      *
  2138.      * @param Sequence|string $sequence
  2139.      *
  2140.      * @return string
  2141.      *
  2142.      * @throws Exception If not supported on this platform.
  2143.      */
  2144.     public function getDropSequenceSQL($sequence)
  2145.     {
  2146.         if (! $this->supportsSequences()) {
  2147.             throw Exception::notSupported(__METHOD__);
  2148.         }
  2149.         if ($sequence instanceof Sequence) {
  2150.             Deprecation::trigger(
  2151.                 'doctrine/dbal',
  2152.                 'https://github.com/doctrine/dbal/issues/4798',
  2153.                 'Passing $sequence as a Sequence object to %s is deprecated. Pass it as a quoted name instead.',
  2154.                 __METHOD__,
  2155.             );
  2156.             $sequence $sequence->getQuotedName($this);
  2157.         }
  2158.         return 'DROP SEQUENCE ' $sequence;
  2159.     }
  2160.     /**
  2161.      * Returns the SQL to create a constraint on a table on this platform.
  2162.      *
  2163.      * @deprecated Use {@see getCreateIndexSQL()}, {@see getCreateForeignKeySQL()}
  2164.      *             or {@see getCreateUniqueConstraintSQL()} instead.
  2165.      *
  2166.      * @param Table|string $table
  2167.      *
  2168.      * @return string
  2169.      *
  2170.      * @throws InvalidArgumentException
  2171.      */
  2172.     public function getCreateConstraintSQL(Constraint $constraint$table)
  2173.     {
  2174.         if ($table instanceof Table) {
  2175.             Deprecation::trigger(
  2176.                 'doctrine/dbal',
  2177.                 'https://github.com/doctrine/dbal/issues/4798',
  2178.                 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.',
  2179.                 __METHOD__,
  2180.             );
  2181.             $table $table->getQuotedName($this);
  2182.         }
  2183.         $query 'ALTER TABLE ' $table ' ADD CONSTRAINT ' $constraint->getQuotedName($this);
  2184.         $columnList '(' implode(', '$constraint->getQuotedColumns($this)) . ')';
  2185.         $referencesClause '';
  2186.         if ($constraint instanceof Index) {
  2187.             if ($constraint->isPrimary()) {
  2188.                 $query .= ' PRIMARY KEY';
  2189.             } elseif ($constraint->isUnique()) {
  2190.                 $query .= ' UNIQUE';
  2191.             } else {
  2192.                 throw new InvalidArgumentException(
  2193.                     'Can only create primary or unique constraints, no common indexes with getCreateConstraintSQL().',
  2194.                 );
  2195.             }
  2196.         } elseif ($constraint instanceof UniqueConstraint) {
  2197.             $query .= ' UNIQUE';
  2198.         } elseif ($constraint instanceof ForeignKeyConstraint) {
  2199.             $query .= ' FOREIGN KEY';
  2200.             $referencesClause ' REFERENCES ' $constraint->getQuotedForeignTableName($this) .
  2201.                 ' (' implode(', '$constraint->getQuotedForeignColumns($this)) . ')';
  2202.         }
  2203.         $query .= ' ' $columnList $referencesClause;
  2204.         return $query;
  2205.     }
  2206.     /**
  2207.      * Returns the SQL to create an index on a table on this platform.
  2208.      *
  2209.      * @param Table|string $table The name of the table on which the index is to be created.
  2210.      *
  2211.      * @return string
  2212.      *
  2213.      * @throws InvalidArgumentException
  2214.      */
  2215.     public function getCreateIndexSQL(Index $index$table)
  2216.     {
  2217.         if ($table instanceof Table) {
  2218.             Deprecation::trigger(
  2219.                 'doctrine/dbal',
  2220.                 'https://github.com/doctrine/dbal/issues/4798',
  2221.                 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.',
  2222.                 __METHOD__,
  2223.             );
  2224.             $table $table->getQuotedName($this);
  2225.         }
  2226.         $name    $index->getQuotedName($this);
  2227.         $columns $index->getColumns();
  2228.         if (count($columns) === 0) {
  2229.             throw new InvalidArgumentException(sprintf(
  2230.                 'Incomplete or invalid index definition %s on table %s',
  2231.                 $name,
  2232.                 $table,
  2233.             ));
  2234.         }
  2235.         if ($index->isPrimary()) {
  2236.             return $this->getCreatePrimaryKeySQL($index$table);
  2237.         }
  2238.         $query  'CREATE ' $this->getCreateIndexSQLFlags($index) . 'INDEX ' $name ' ON ' $table;
  2239.         $query .= ' (' $this->getIndexFieldDeclarationListSQL($index) . ')' $this->getPartialIndexSQL($index);
  2240.         return $query;
  2241.     }
  2242.     /**
  2243.      * Adds condition for partial index.
  2244.      *
  2245.      * @return string
  2246.      */
  2247.     protected function getPartialIndexSQL(Index $index)
  2248.     {
  2249.         if ($this->supportsPartialIndexes() && $index->hasOption('where')) {
  2250.             return ' WHERE ' $index->getOption('where');
  2251.         }
  2252.         return '';
  2253.     }
  2254.     /**
  2255.      * Adds additional flags for index generation.
  2256.      *
  2257.      * @return string
  2258.      */
  2259.     protected function getCreateIndexSQLFlags(Index $index)
  2260.     {
  2261.         return $index->isUnique() ? 'UNIQUE ' '';
  2262.     }
  2263.     /**
  2264.      * Returns the SQL to create an unnamed primary key constraint.
  2265.      *
  2266.      * @param Table|string $table
  2267.      *
  2268.      * @return string
  2269.      */
  2270.     public function getCreatePrimaryKeySQL(Index $index$table)
  2271.     {
  2272.         if ($table instanceof Table) {
  2273.             Deprecation::trigger(
  2274.                 'doctrine/dbal',
  2275.                 'https://github.com/doctrine/dbal/issues/4798',
  2276.                 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.',
  2277.                 __METHOD__,
  2278.             );
  2279.             $table $table->getQuotedName($this);
  2280.         }
  2281.         return 'ALTER TABLE ' $table ' ADD PRIMARY KEY (' $this->getIndexFieldDeclarationListSQL($index) . ')';
  2282.     }
  2283.     /**
  2284.      * Returns the SQL to create a named schema.
  2285.      *
  2286.      * @param string $schemaName
  2287.      *
  2288.      * @return string
  2289.      *
  2290.      * @throws Exception If not supported on this platform.
  2291.      */
  2292.     public function getCreateSchemaSQL($schemaName)
  2293.     {
  2294.         if (! $this->supportsSchemas()) {
  2295.             throw Exception::notSupported(__METHOD__);
  2296.         }
  2297.         return 'CREATE SCHEMA ' $schemaName;
  2298.     }
  2299.     /**
  2300.      * Returns the SQL to create a unique constraint on a table on this platform.
  2301.      */
  2302.     public function getCreateUniqueConstraintSQL(UniqueConstraint $constraintstring $tableName): string
  2303.     {
  2304.         return $this->getCreateConstraintSQL($constraint$tableName);
  2305.     }
  2306.     /**
  2307.      * Returns the SQL snippet to drop a schema.
  2308.      *
  2309.      * @throws Exception If not supported on this platform.
  2310.      */
  2311.     public function getDropSchemaSQL(string $schemaName): string
  2312.     {
  2313.         if (! $this->supportsSchemas()) {
  2314.             throw Exception::notSupported(__METHOD__);
  2315.         }
  2316.         return 'DROP SCHEMA ' $schemaName;
  2317.     }
  2318.     /**
  2319.      * Quotes a string so that it can be safely used as a table or column name,
  2320.      * even if it is a reserved word of the platform. This also detects identifier
  2321.      * chains separated by dot and quotes them independently.
  2322.      *
  2323.      * NOTE: Just because you CAN use quoted identifiers doesn't mean
  2324.      * you SHOULD use them. In general, they end up causing way more
  2325.      * problems than they solve.
  2326.      *
  2327.      * @param string $str The identifier name to be quoted.
  2328.      *
  2329.      * @return string The quoted identifier string.
  2330.      */
  2331.     public function quoteIdentifier($str)
  2332.     {
  2333.         if (strpos($str'.') !== false) {
  2334.             $parts array_map([$this'quoteSingleIdentifier'], explode('.'$str));
  2335.             return implode('.'$parts);
  2336.         }
  2337.         return $this->quoteSingleIdentifier($str);
  2338.     }
  2339.     /**
  2340.      * Quotes a single identifier (no dot chain separation).
  2341.      *
  2342.      * @param string $str The identifier name to be quoted.
  2343.      *
  2344.      * @return string The quoted identifier string.
  2345.      */
  2346.     public function quoteSingleIdentifier($str)
  2347.     {
  2348.         $c $this->getIdentifierQuoteCharacter();
  2349.         return $c str_replace($c$c $c$str) . $c;
  2350.     }
  2351.     /**
  2352.      * Returns the SQL to create a new foreign key.
  2353.      *
  2354.      * @param ForeignKeyConstraint $foreignKey The foreign key constraint.
  2355.      * @param Table|string         $table      The name of the table on which the foreign key is to be created.
  2356.      *
  2357.      * @return string
  2358.      */
  2359.     public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey$table)
  2360.     {
  2361.         if ($table instanceof Table) {
  2362.             Deprecation::trigger(
  2363.                 'doctrine/dbal',
  2364.                 'https://github.com/doctrine/dbal/issues/4798',
  2365.                 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.',
  2366.                 __METHOD__,
  2367.             );
  2368.             $table $table->getQuotedName($this);
  2369.         }
  2370.         return 'ALTER TABLE ' $table ' ADD ' $this->getForeignKeyDeclarationSQL($foreignKey);
  2371.     }
  2372.     /**
  2373.      * Gets the SQL statements for altering an existing table.
  2374.      *
  2375.      * This method returns an array of SQL statements, since some platforms need several statements.
  2376.      *
  2377.      * @return list<string>
  2378.      *
  2379.      * @throws Exception If not supported on this platform.
  2380.      */
  2381.     public function getAlterTableSQL(TableDiff $diff)
  2382.     {
  2383.         throw Exception::notSupported(__METHOD__);
  2384.     }
  2385.     /** @return list<string> */
  2386.     public function getRenameTableSQL(string $oldNamestring $newName): array
  2387.     {
  2388.         return [
  2389.             sprintf('ALTER TABLE %s RENAME TO %s'$oldName$newName),
  2390.         ];
  2391.     }
  2392.     /**
  2393.      * @param mixed[] $columnSql
  2394.      *
  2395.      * @return bool
  2396.      */
  2397.     protected function onSchemaAlterTableAddColumn(Column $columnTableDiff $diff, &$columnSql)
  2398.     {
  2399.         if ($this->_eventManager === null) {
  2400.             return false;
  2401.         }
  2402.         if (! $this->_eventManager->hasListeners(Events::onSchemaAlterTableAddColumn)) {
  2403.             return false;
  2404.         }
  2405.         Deprecation::trigger(
  2406.             'doctrine/dbal',
  2407.             'https://github.com/doctrine/dbal/issues/5784',
  2408.             'Subscribing to %s events is deprecated.',
  2409.             Events::onSchemaAlterTableAddColumn,
  2410.         );
  2411.         $eventArgs = new SchemaAlterTableAddColumnEventArgs($column$diff$this);
  2412.         $this->_eventManager->dispatchEvent(Events::onSchemaAlterTableAddColumn$eventArgs);
  2413.         $columnSql array_merge($columnSql$eventArgs->getSql());
  2414.         return $eventArgs->isDefaultPrevented();
  2415.     }
  2416.     /**
  2417.      * @param string[] $columnSql
  2418.      *
  2419.      * @return bool
  2420.      */
  2421.     protected function onSchemaAlterTableRemoveColumn(Column $columnTableDiff $diff, &$columnSql)
  2422.     {
  2423.         if ($this->_eventManager === null) {
  2424.             return false;
  2425.         }
  2426.         if (! $this->_eventManager->hasListeners(Events::onSchemaAlterTableRemoveColumn)) {
  2427.             return false;
  2428.         }
  2429.         Deprecation::trigger(
  2430.             'doctrine/dbal',
  2431.             'https://github.com/doctrine/dbal/issues/5784',
  2432.             'Subscribing to %s events is deprecated.',
  2433.             Events::onSchemaAlterTableRemoveColumn,
  2434.         );
  2435.         $eventArgs = new SchemaAlterTableRemoveColumnEventArgs($column$diff$this);
  2436.         $this->_eventManager->dispatchEvent(Events::onSchemaAlterTableRemoveColumn$eventArgs);
  2437.         $columnSql array_merge($columnSql$eventArgs->getSql());
  2438.         return $eventArgs->isDefaultPrevented();
  2439.     }
  2440.     /**
  2441.      * @param string[] $columnSql
  2442.      *
  2443.      * @return bool
  2444.      */
  2445.     protected function onSchemaAlterTableChangeColumn(ColumnDiff $columnDiffTableDiff $diff, &$columnSql)
  2446.     {
  2447.         if ($this->_eventManager === null) {
  2448.             return false;
  2449.         }
  2450.         if (! $this->_eventManager->hasListeners(Events::onSchemaAlterTableChangeColumn)) {
  2451.             return false;
  2452.         }
  2453.         Deprecation::trigger(
  2454.             'doctrine/dbal',
  2455.             'https://github.com/doctrine/dbal/issues/5784',
  2456.             'Subscribing to %s events is deprecated.',
  2457.             Events::onSchemaAlterTableChangeColumn,
  2458.         );
  2459.         $eventArgs = new SchemaAlterTableChangeColumnEventArgs($columnDiff$diff$this);
  2460.         $this->_eventManager->dispatchEvent(Events::onSchemaAlterTableChangeColumn$eventArgs);
  2461.         $columnSql array_merge($columnSql$eventArgs->getSql());
  2462.         return $eventArgs->isDefaultPrevented();
  2463.     }
  2464.     /**
  2465.      * @param string   $oldColumnName
  2466.      * @param string[] $columnSql
  2467.      *
  2468.      * @return bool
  2469.      */
  2470.     protected function onSchemaAlterTableRenameColumn($oldColumnNameColumn $columnTableDiff $diff, &$columnSql)
  2471.     {
  2472.         if ($this->_eventManager === null) {
  2473.             return false;
  2474.         }
  2475.         if (! $this->_eventManager->hasListeners(Events::onSchemaAlterTableRenameColumn)) {
  2476.             return false;
  2477.         }
  2478.         Deprecation::trigger(
  2479.             'doctrine/dbal',
  2480.             'https://github.com/doctrine/dbal/issues/5784',
  2481.             'Subscribing to %s events is deprecated.',
  2482.             Events::onSchemaAlterTableRenameColumn,
  2483.         );
  2484.         $eventArgs = new SchemaAlterTableRenameColumnEventArgs($oldColumnName$column$diff$this);
  2485.         $this->_eventManager->dispatchEvent(Events::onSchemaAlterTableRenameColumn$eventArgs);
  2486.         $columnSql array_merge($columnSql$eventArgs->getSql());
  2487.         return $eventArgs->isDefaultPrevented();
  2488.     }
  2489.     /**
  2490.      * @param string[] $sql
  2491.      *
  2492.      * @return bool
  2493.      */
  2494.     protected function onSchemaAlterTable(TableDiff $diff, &$sql)
  2495.     {
  2496.         if ($this->_eventManager === null) {
  2497.             return false;
  2498.         }
  2499.         if (! $this->_eventManager->hasListeners(Events::onSchemaAlterTable)) {
  2500.             return false;
  2501.         }
  2502.         Deprecation::trigger(
  2503.             'doctrine/dbal',
  2504.             'https://github.com/doctrine/dbal/issues/5784',
  2505.             'Subscribing to %s events is deprecated.',
  2506.             Events::onSchemaAlterTable,
  2507.         );
  2508.         $eventArgs = new SchemaAlterTableEventArgs($diff$this);
  2509.         $this->_eventManager->dispatchEvent(Events::onSchemaAlterTable$eventArgs);
  2510.         $sql array_merge($sql$eventArgs->getSql());
  2511.         return $eventArgs->isDefaultPrevented();
  2512.     }
  2513.     /** @return string[] */
  2514.     protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
  2515.     {
  2516.         $tableNameSQL = ($diff->getOldTable() ?? $diff->getName($this))->getQuotedName($this);
  2517.         $sql = [];
  2518.         if ($this->supportsForeignKeyConstraints()) {
  2519.             foreach ($diff->getDroppedForeignKeys() as $foreignKey) {
  2520.                 if ($foreignKey instanceof ForeignKeyConstraint) {
  2521.                     $foreignKey $foreignKey->getQuotedName($this);
  2522.                 }
  2523.                 $sql[] = $this->getDropForeignKeySQL($foreignKey$tableNameSQL);
  2524.             }
  2525.             foreach ($diff->getModifiedForeignKeys() as $foreignKey) {
  2526.                 $sql[] = $this->getDropForeignKeySQL($foreignKey->getQuotedName($this), $tableNameSQL);
  2527.             }
  2528.         }
  2529.         foreach ($diff->getDroppedIndexes() as $index) {
  2530.             $sql[] = $this->getDropIndexSQL($index->getQuotedName($this), $tableNameSQL);
  2531.         }
  2532.         foreach ($diff->getModifiedIndexes() as $index) {
  2533.             $sql[] = $this->getDropIndexSQL($index->getQuotedName($this), $tableNameSQL);
  2534.         }
  2535.         return $sql;
  2536.     }
  2537.     /** @return string[] */
  2538.     protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff)
  2539.     {
  2540.         $sql     = [];
  2541.         $newName $diff->getNewName();
  2542.         if ($newName !== false) {
  2543.             $tableNameSQL $newName->getQuotedName($this);
  2544.         } else {
  2545.             $tableNameSQL = ($diff->getOldTable() ?? $diff->getName($this))->getQuotedName($this);
  2546.         }
  2547.         if ($this->supportsForeignKeyConstraints()) {
  2548.             foreach ($diff->getAddedForeignKeys() as $foreignKey) {
  2549.                 $sql[] = $this->getCreateForeignKeySQL($foreignKey$tableNameSQL);
  2550.             }
  2551.             foreach ($diff->getModifiedForeignKeys() as $foreignKey) {
  2552.                 $sql[] = $this->getCreateForeignKeySQL($foreignKey$tableNameSQL);
  2553.             }
  2554.         }
  2555.         foreach ($diff->getAddedIndexes() as $index) {
  2556.             $sql[] = $this->getCreateIndexSQL($index$tableNameSQL);
  2557.         }
  2558.         foreach ($diff->getModifiedIndexes() as $index) {
  2559.             $sql[] = $this->getCreateIndexSQL($index$tableNameSQL);
  2560.         }
  2561.         foreach ($diff->getRenamedIndexes() as $oldIndexName => $index) {
  2562.             $oldIndexName = new Identifier($oldIndexName);
  2563.             $sql          array_merge(
  2564.                 $sql,
  2565.                 $this->getRenameIndexSQL($oldIndexName->getQuotedName($this), $index$tableNameSQL),
  2566.             );
  2567.         }
  2568.         return $sql;
  2569.     }
  2570.     /**
  2571.      * Returns the SQL for renaming an index on a table.
  2572.      *
  2573.      * @param string $oldIndexName The name of the index to rename from.
  2574.      * @param Index  $index        The definition of the index to rename to.
  2575.      * @param string $tableName    The table to rename the given index on.
  2576.      *
  2577.      * @return string[] The sequence of SQL statements for renaming the given index.
  2578.      */
  2579.     protected function getRenameIndexSQL($oldIndexNameIndex $index$tableName)
  2580.     {
  2581.         return [
  2582.             $this->getDropIndexSQL($oldIndexName$tableName),
  2583.             $this->getCreateIndexSQL($index$tableName),
  2584.         ];
  2585.     }
  2586.     /**
  2587.      * Gets declaration of a number of columns in bulk.
  2588.      *
  2589.      * @param mixed[][] $columns A multidimensional associative array.
  2590.      *                           The first dimension determines the column name, while the second
  2591.      *                           dimension is keyed with the name of the properties
  2592.      *                           of the column being declared as array indexes. Currently, the types
  2593.      *                           of supported column properties are as follows:
  2594.      *
  2595.      *      length
  2596.      *          Integer value that determines the maximum length of the text
  2597.      *          column. If this argument is missing the column should be
  2598.      *          declared to have the longest length allowed by the DBMS.
  2599.      *
  2600.      *      default
  2601.      *          Text value to be used as default for this column.
  2602.      *
  2603.      *      notnull
  2604.      *          Boolean flag that indicates whether this column is constrained
  2605.      *          to not be set to null.
  2606.      *      charset
  2607.      *          Text value with the default CHARACTER SET for this column.
  2608.      *      collation
  2609.      *          Text value with the default COLLATION for this column.
  2610.      *      unique
  2611.      *          unique constraint
  2612.      *
  2613.      * @return string
  2614.      */
  2615.     public function getColumnDeclarationListSQL(array $columns)
  2616.     {
  2617.         $declarations = [];
  2618.         foreach ($columns as $name => $column) {
  2619.             $declarations[] = $this->getColumnDeclarationSQL($name$column);
  2620.         }
  2621.         return implode(', '$declarations);
  2622.     }
  2623.     /**
  2624.      * Obtains DBMS specific SQL code portion needed to declare a generic type
  2625.      * column to be used in statements like CREATE TABLE.
  2626.      *
  2627.      * @param string  $name   The name the column to be declared.
  2628.      * @param mixed[] $column An associative array with the name of the properties
  2629.      *                        of the column being declared as array indexes. Currently, the types
  2630.      *                        of supported column properties are as follows:
  2631.      *
  2632.      *      length
  2633.      *          Integer value that determines the maximum length of the text
  2634.      *          column. If this argument is missing the column should be
  2635.      *          declared to have the longest length allowed by the DBMS.
  2636.      *
  2637.      *      default
  2638.      *          Text value to be used as default for this column.
  2639.      *
  2640.      *      notnull
  2641.      *          Boolean flag that indicates whether this column is constrained
  2642.      *          to not be set to null.
  2643.      *      charset
  2644.      *          Text value with the default CHARACTER SET for this column.
  2645.      *      collation
  2646.      *          Text value with the default COLLATION for this column.
  2647.      *      unique
  2648.      *          unique constraint
  2649.      *      check
  2650.      *          column check constraint
  2651.      *      columnDefinition
  2652.      *          a string that defines the complete column
  2653.      *
  2654.      * @return string DBMS specific SQL code portion that should be used to declare the column.
  2655.      *
  2656.      * @throws Exception
  2657.      */
  2658.     public function getColumnDeclarationSQL($name, array $column)
  2659.     {
  2660.         if (isset($column['columnDefinition'])) {
  2661.             $declaration $this->getCustomTypeDeclarationSQL($column);
  2662.         } else {
  2663.             $default $this->getDefaultValueDeclarationSQL($column);
  2664.             $charset = ! empty($column['charset']) ?
  2665.                 ' ' $this->getColumnCharsetDeclarationSQL($column['charset']) : '';
  2666.             $collation = ! empty($column['collation']) ?
  2667.                 ' ' $this->getColumnCollationDeclarationSQL($column['collation']) : '';
  2668.             $notnull = ! empty($column['notnull']) ? ' NOT NULL' '';
  2669.             if (! empty($column['unique'])) {
  2670.                 Deprecation::trigger(
  2671.                     'doctrine/dbal',
  2672.                     'https://github.com/doctrine/dbal/pull/5656',
  2673.                     'The usage of the "unique" column property is deprecated. Use unique constraints instead.',
  2674.                 );
  2675.                 $unique ' ' $this->getUniqueFieldDeclarationSQL();
  2676.             } else {
  2677.                 $unique '';
  2678.             }
  2679.             if (! empty($column['check'])) {
  2680.                 Deprecation::trigger(
  2681.                     'doctrine/dbal',
  2682.                     'https://github.com/doctrine/dbal/pull/5656',
  2683.                     'The usage of the "check" column property is deprecated.',
  2684.                 );
  2685.                 $check ' ' $column['check'];
  2686.             } else {
  2687.                 $check '';
  2688.             }
  2689.             $typeDecl    $column['type']->getSQLDeclaration($column$this);
  2690.             $declaration $typeDecl $charset $default $notnull $unique $check $collation;
  2691.             if ($this->supportsInlineColumnComments() && isset($column['comment']) && $column['comment'] !== '') {
  2692.                 $declaration .= ' ' $this->getInlineColumnCommentSQL($column['comment']);
  2693.             }
  2694.         }
  2695.         return $name ' ' $declaration;
  2696.     }
  2697.     /**
  2698.      * Returns the SQL snippet that declares a floating point column of arbitrary precision.
  2699.      *
  2700.      * @param mixed[] $column
  2701.      *
  2702.      * @return string
  2703.      */
  2704.     public function getDecimalTypeDeclarationSQL(array $column)
  2705.     {
  2706.         if (empty($column['precision'])) {
  2707.             if (! isset($column['precision'])) {
  2708.                 Deprecation::trigger(
  2709.                     'doctrine/dbal',
  2710.                     'https://github.com/doctrine/dbal/pull/5637',
  2711.                     'Relying on the default decimal column precision is deprecated'
  2712.                         ', specify the precision explicitly.',
  2713.                 );
  2714.             }
  2715.             $precision 10;
  2716.         } else {
  2717.             $precision $column['precision'];
  2718.         }
  2719.         if (empty($column['scale'])) {
  2720.             if (! isset($column['scale'])) {
  2721.                 Deprecation::trigger(
  2722.                     'doctrine/dbal',
  2723.                     'https://github.com/doctrine/dbal/pull/5637',
  2724.                     'Relying on the default decimal column scale is deprecated'
  2725.                         ', specify the scale explicitly.',
  2726.                 );
  2727.             }
  2728.             $scale 0;
  2729.         } else {
  2730.             $scale $column['scale'];
  2731.         }
  2732.         return 'NUMERIC(' $precision ', ' $scale ')';
  2733.     }
  2734.     /**
  2735.      * Obtains DBMS specific SQL code portion needed to set a default value
  2736.      * declaration to be used in statements like CREATE TABLE.
  2737.      *
  2738.      * @param mixed[] $column The column definition array.
  2739.      *
  2740.      * @return string DBMS specific SQL code portion needed to set a default value.
  2741.      */
  2742.     public function getDefaultValueDeclarationSQL($column)
  2743.     {
  2744.         if (! isset($column['default'])) {
  2745.             return empty($column['notnull']) ? ' DEFAULT NULL' '';
  2746.         }
  2747.         $default $column['default'];
  2748.         if (! isset($column['type'])) {
  2749.             return " DEFAULT '" $default "'";
  2750.         }
  2751.         $type $column['type'];
  2752.         if ($type instanceof Types\PhpIntegerMappingType) {
  2753.             return ' DEFAULT ' $default;
  2754.         }
  2755.         if ($type instanceof Types\PhpDateTimeMappingType && $default === $this->getCurrentTimestampSQL()) {
  2756.             return ' DEFAULT ' $this->getCurrentTimestampSQL();
  2757.         }
  2758.         if ($type instanceof Types\TimeType && $default === $this->getCurrentTimeSQL()) {
  2759.             return ' DEFAULT ' $this->getCurrentTimeSQL();
  2760.         }
  2761.         if ($type instanceof Types\DateType && $default === $this->getCurrentDateSQL()) {
  2762.             return ' DEFAULT ' $this->getCurrentDateSQL();
  2763.         }
  2764.         if ($type instanceof Types\BooleanType) {
  2765.             return ' DEFAULT ' $this->convertBooleans($default);
  2766.         }
  2767.         return ' DEFAULT ' $this->quoteStringLiteral($default);
  2768.     }
  2769.     /**
  2770.      * Obtains DBMS specific SQL code portion needed to set a CHECK constraint
  2771.      * declaration to be used in statements like CREATE TABLE.
  2772.      *
  2773.      * @param string[]|mixed[][] $definition The check definition.
  2774.      *
  2775.      * @return string DBMS specific SQL code portion needed to set a CHECK constraint.
  2776.      */
  2777.     public function getCheckDeclarationSQL(array $definition)
  2778.     {
  2779.         $constraints = [];
  2780.         foreach ($definition as $column => $def) {
  2781.             if (is_string($def)) {
  2782.                 $constraints[] = 'CHECK (' $def ')';
  2783.             } else {
  2784.                 if (isset($def['min'])) {
  2785.                     $constraints[] = 'CHECK (' $column ' >= ' $def['min'] . ')';
  2786.                 }
  2787.                 if (isset($def['max'])) {
  2788.                     $constraints[] = 'CHECK (' $column ' <= ' $def['max'] . ')';
  2789.                 }
  2790.             }
  2791.         }
  2792.         return implode(', '$constraints);
  2793.     }
  2794.     /**
  2795.      * Obtains DBMS specific SQL code portion needed to set a unique
  2796.      * constraint declaration to be used in statements like CREATE TABLE.
  2797.      *
  2798.      * @param string           $name       The name of the unique constraint.
  2799.      * @param UniqueConstraint $constraint The unique constraint definition.
  2800.      *
  2801.      * @return string DBMS specific SQL code portion needed to set a constraint.
  2802.      *
  2803.      * @throws InvalidArgumentException
  2804.      */
  2805.     public function getUniqueConstraintDeclarationSQL($nameUniqueConstraint $constraint)
  2806.     {
  2807.         $columns $constraint->getQuotedColumns($this);
  2808.         $name    = new Identifier($name);
  2809.         if (count($columns) === 0) {
  2810.             throw new InvalidArgumentException("Incomplete definition. 'columns' required.");
  2811.         }
  2812.         $constraintFlags array_merge(['UNIQUE'], array_map('strtoupper'$constraint->getFlags()));
  2813.         $constraintName  $name->getQuotedName($this);
  2814.         $columnListNames $this->getColumnsFieldDeclarationListSQL($columns);
  2815.         return sprintf('CONSTRAINT %s %s (%s)'$constraintNameimplode(' '$constraintFlags), $columnListNames);
  2816.     }
  2817.     /**
  2818.      * Obtains DBMS specific SQL code portion needed to set an index
  2819.      * declaration to be used in statements like CREATE TABLE.
  2820.      *
  2821.      * @param string $name  The name of the index.
  2822.      * @param Index  $index The index definition.
  2823.      *
  2824.      * @return string DBMS specific SQL code portion needed to set an index.
  2825.      *
  2826.      * @throws InvalidArgumentException
  2827.      */
  2828.     public function getIndexDeclarationSQL($nameIndex $index)
  2829.     {
  2830.         $columns $index->getColumns();
  2831.         $name    = new Identifier($name);
  2832.         if (count($columns) === 0) {
  2833.             throw new InvalidArgumentException("Incomplete definition. 'columns' required.");
  2834.         }
  2835.         return $this->getCreateIndexSQLFlags($index) . 'INDEX ' $name->getQuotedName($this)
  2836.             . ' (' $this->getIndexFieldDeclarationListSQL($index) . ')' $this->getPartialIndexSQL($index);
  2837.     }
  2838.     /**
  2839.      * Obtains SQL code portion needed to create a custom column,
  2840.      * e.g. when a column has the "columnDefinition" keyword.
  2841.      * Only "AUTOINCREMENT" and "PRIMARY KEY" are added if appropriate.
  2842.      *
  2843.      * @deprecated
  2844.      *
  2845.      * @param mixed[] $column
  2846.      *
  2847.      * @return string
  2848.      */
  2849.     public function getCustomTypeDeclarationSQL(array $column)
  2850.     {
  2851.         Deprecation::triggerIfCalledFromOutside(
  2852.             'doctrine/dbal',
  2853.             'https://github.com/doctrine/dbal/pull/5527',
  2854.             '%s is deprecated.',
  2855.             __METHOD__,
  2856.         );
  2857.         return $column['columnDefinition'];
  2858.     }
  2859.     /**
  2860.      * Obtains DBMS specific SQL code portion needed to set an index
  2861.      * declaration to be used in statements like CREATE TABLE.
  2862.      *
  2863.      * @deprecated
  2864.      */
  2865.     public function getIndexFieldDeclarationListSQL(Index $index): string
  2866.     {
  2867.         Deprecation::triggerIfCalledFromOutside(
  2868.             'doctrine/dbal',
  2869.             'https://github.com/doctrine/dbal/pull/5527',
  2870.             '%s is deprecated.',
  2871.             __METHOD__,
  2872.         );
  2873.         return implode(', '$index->getQuotedColumns($this));
  2874.     }
  2875.     /**
  2876.      * Obtains DBMS specific SQL code portion needed to set an index
  2877.      * declaration to be used in statements like CREATE TABLE.
  2878.      *
  2879.      * @deprecated
  2880.      *
  2881.      * @param mixed[] $columns
  2882.      */
  2883.     public function getColumnsFieldDeclarationListSQL(array $columns): string
  2884.     {
  2885.         Deprecation::triggerIfCalledFromOutside(
  2886.             'doctrine/dbal',
  2887.             'https://github.com/doctrine/dbal/pull/5527',
  2888.             '%s is deprecated.',
  2889.             __METHOD__,
  2890.         );
  2891.         $ret = [];
  2892.         foreach ($columns as $column => $definition) {
  2893.             if (is_array($definition)) {
  2894.                 $ret[] = $column;
  2895.             } else {
  2896.                 $ret[] = $definition;
  2897.             }
  2898.         }
  2899.         return implode(', '$ret);
  2900.     }
  2901.     /**
  2902.      * Returns the required SQL string that fits between CREATE ... TABLE
  2903.      * to create the table as a temporary table.
  2904.      *
  2905.      * Should be overridden in driver classes to return the correct string for the
  2906.      * specific database type.
  2907.      *
  2908.      * The default is to return the string "TEMPORARY" - this will result in a
  2909.      * SQL error for any database that does not support temporary tables, or that
  2910.      * requires a different SQL command from "CREATE TEMPORARY TABLE".
  2911.      *
  2912.      * @deprecated
  2913.      *
  2914.      * @return string The string required to be placed between "CREATE" and "TABLE"
  2915.      *                to generate a temporary table, if possible.
  2916.      */
  2917.     public function getTemporaryTableSQL()
  2918.     {
  2919.         Deprecation::trigger(
  2920.             'doctrine/dbal',
  2921.             'https://github.com/doctrine/dbal/pull/4724',
  2922.             'AbstractPlatform::getTemporaryTableSQL() is deprecated.',
  2923.         );
  2924.         return 'TEMPORARY';
  2925.     }
  2926.     /**
  2927.      * Some vendors require temporary table names to be qualified specially.
  2928.      *
  2929.      * @param string $tableName
  2930.      *
  2931.      * @return string
  2932.      */
  2933.     public function getTemporaryTableName($tableName)
  2934.     {
  2935.         return $tableName;
  2936.     }
  2937.     /**
  2938.      * Obtain DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
  2939.      * of a column declaration to be used in statements like CREATE TABLE.
  2940.      *
  2941.      * @return string DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
  2942.      *                of a column declaration.
  2943.      */
  2944.     public function getForeignKeyDeclarationSQL(ForeignKeyConstraint $foreignKey)
  2945.     {
  2946.         $sql  $this->getForeignKeyBaseDeclarationSQL($foreignKey);
  2947.         $sql .= $this->getAdvancedForeignKeyOptionsSQL($foreignKey);
  2948.         return $sql;
  2949.     }
  2950.     /**
  2951.      * Returns the FOREIGN KEY query section dealing with non-standard options
  2952.      * as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
  2953.      *
  2954.      * @param ForeignKeyConstraint $foreignKey The foreign key definition.
  2955.      *
  2956.      * @return string
  2957.      */
  2958.     public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey)
  2959.     {
  2960.         $query '';
  2961.         if ($foreignKey->hasOption('onUpdate')) {
  2962.             $query .= ' ON UPDATE ' $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onUpdate'));
  2963.         }
  2964.         if ($foreignKey->hasOption('onDelete')) {
  2965.             $query .= ' ON DELETE ' $this->getForeignKeyReferentialActionSQL($foreignKey->getOption('onDelete'));
  2966.         }
  2967.         return $query;
  2968.     }
  2969.     /**
  2970.      * Returns the given referential action in uppercase if valid, otherwise throws an exception.
  2971.      *
  2972.      * @param string $action The foreign key referential action.
  2973.      *
  2974.      * @return string
  2975.      *
  2976.      * @throws InvalidArgumentException If unknown referential action given.
  2977.      */
  2978.     public function getForeignKeyReferentialActionSQL($action)
  2979.     {
  2980.         $upper strtoupper($action);
  2981.         switch ($upper) {
  2982.             case 'CASCADE':
  2983.             case 'SET NULL':
  2984.             case 'NO ACTION':
  2985.             case 'RESTRICT':
  2986.             case 'SET DEFAULT':
  2987.                 return $upper;
  2988.             default:
  2989.                 throw new InvalidArgumentException('Invalid foreign key action: ' $upper);
  2990.         }
  2991.     }
  2992.     /**
  2993.      * Obtains DBMS specific SQL code portion needed to set the FOREIGN KEY constraint
  2994.      * of a column declaration to be used in statements like CREATE TABLE.
  2995.      *
  2996.      * @return string
  2997.      *
  2998.      * @throws InvalidArgumentException
  2999.      */
  3000.     public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey)
  3001.     {
  3002.         $sql '';
  3003.         if (strlen($foreignKey->getName()) > 0) {
  3004.             $sql .= 'CONSTRAINT ' $foreignKey->getQuotedName($this) . ' ';
  3005.         }
  3006.         $sql .= 'FOREIGN KEY (';
  3007.         if (count($foreignKey->getLocalColumns()) === 0) {
  3008.             throw new InvalidArgumentException("Incomplete definition. 'local' required.");
  3009.         }
  3010.         if (count($foreignKey->getForeignColumns()) === 0) {
  3011.             throw new InvalidArgumentException("Incomplete definition. 'foreign' required.");
  3012.         }
  3013.         if (strlen($foreignKey->getForeignTableName()) === 0) {
  3014.             throw new InvalidArgumentException("Incomplete definition. 'foreignTable' required.");
  3015.         }
  3016.         return $sql implode(', '$foreignKey->getQuotedLocalColumns($this))
  3017.             . ') REFERENCES '
  3018.             $foreignKey->getQuotedForeignTableName($this) . ' ('
  3019.             implode(', '$foreignKey->getQuotedForeignColumns($this)) . ')';
  3020.     }
  3021.     /**
  3022.      * Obtains DBMS specific SQL code portion needed to set the UNIQUE constraint
  3023.      * of a column declaration to be used in statements like CREATE TABLE.
  3024.      *
  3025.      * @deprecated Use UNIQUE in SQL instead.
  3026.      *
  3027.      * @return string DBMS specific SQL code portion needed to set the UNIQUE constraint
  3028.      *                of a column declaration.
  3029.      */
  3030.     public function getUniqueFieldDeclarationSQL()
  3031.     {
  3032.         Deprecation::trigger(
  3033.             'doctrine/dbal',
  3034.             'https://github.com/doctrine/dbal/pull/4724',
  3035.             'AbstractPlatform::getUniqueFieldDeclarationSQL() is deprecated. Use UNIQUE in SQL instead.',
  3036.         );
  3037.         return 'UNIQUE';
  3038.     }
  3039.     /**
  3040.      * Obtains DBMS specific SQL code portion needed to set the CHARACTER SET
  3041.      * of a column declaration to be used in statements like CREATE TABLE.
  3042.      *
  3043.      * @param string $charset The name of the charset.
  3044.      *
  3045.      * @return string DBMS specific SQL code portion needed to set the CHARACTER SET
  3046.      *                of a column declaration.
  3047.      */
  3048.     public function getColumnCharsetDeclarationSQL($charset)
  3049.     {
  3050.         return '';
  3051.     }
  3052.     /**
  3053.      * Obtains DBMS specific SQL code portion needed to set the COLLATION
  3054.      * of a column declaration to be used in statements like CREATE TABLE.
  3055.      *
  3056.      * @param string $collation The name of the collation.
  3057.      *
  3058.      * @return string DBMS specific SQL code portion needed to set the COLLATION
  3059.      *                of a column declaration.
  3060.      */
  3061.     public function getColumnCollationDeclarationSQL($collation)
  3062.     {
  3063.         return $this->supportsColumnCollation() ? 'COLLATE ' $this->quoteSingleIdentifier($collation) : '';
  3064.     }
  3065.     /**
  3066.      * Whether the platform prefers identity columns (eg. autoincrement) for ID generation.
  3067.      * Subclasses should override this method to return TRUE if they prefer identity columns.
  3068.      *
  3069.      * @deprecated
  3070.      *
  3071.      * @return bool
  3072.      */
  3073.     public function prefersIdentityColumns()
  3074.     {
  3075.         Deprecation::trigger(
  3076.             'doctrine/dbal',
  3077.             'https://github.com/doctrine/dbal/pull/1519',
  3078.             'AbstractPlatform::prefersIdentityColumns() is deprecated.',
  3079.         );
  3080.         return false;
  3081.     }
  3082.     /**
  3083.      * Some platforms need the boolean values to be converted.
  3084.      *
  3085.      * The default conversion in this implementation converts to integers (false => 0, true => 1).
  3086.      *
  3087.      * Note: if the input is not a boolean the original input might be returned.
  3088.      *
  3089.      * There are two contexts when converting booleans: Literals and Prepared Statements.
  3090.      * This method should handle the literal case
  3091.      *
  3092.      * @param mixed $item A boolean or an array of them.
  3093.      *
  3094.      * @return mixed A boolean database value or an array of them.
  3095.      */
  3096.     public function convertBooleans($item)
  3097.     {
  3098.         if (is_array($item)) {
  3099.             foreach ($item as $k => $value) {
  3100.                 if (! is_bool($value)) {
  3101.                     continue;
  3102.                 }
  3103.                 $item[$k] = (int) $value;
  3104.             }
  3105.         } elseif (is_bool($item)) {
  3106.             $item = (int) $item;
  3107.         }
  3108.         return $item;
  3109.     }
  3110.     /**
  3111.      * Some platforms have boolean literals that needs to be correctly converted
  3112.      *
  3113.      * The default conversion tries to convert value into bool "(bool)$item"
  3114.      *
  3115.      * @param T $item
  3116.      *
  3117.      * @return (T is null ? null : bool)
  3118.      *
  3119.      * @template T
  3120.      */
  3121.     public function convertFromBoolean($item)
  3122.     {
  3123.         return $item === null null : (bool) $item;
  3124.     }
  3125.     /**
  3126.      * This method should handle the prepared statements case. When there is no
  3127.      * distinction, it's OK to use the same method.
  3128.      *
  3129.      * Note: if the input is not a boolean the original input might be returned.
  3130.      *
  3131.      * @param mixed $item A boolean or an array of them.
  3132.      *
  3133.      * @return mixed A boolean database value or an array of them.
  3134.      */
  3135.     public function convertBooleansToDatabaseValue($item)
  3136.     {
  3137.         return $this->convertBooleans($item);
  3138.     }
  3139.     /**
  3140.      * Returns the SQL specific for the platform to get the current date.
  3141.      *
  3142.      * @return string
  3143.      */
  3144.     public function getCurrentDateSQL()
  3145.     {
  3146.         return 'CURRENT_DATE';
  3147.     }
  3148.     /**
  3149.      * Returns the SQL specific for the platform to get the current time.
  3150.      *
  3151.      * @return string
  3152.      */
  3153.     public function getCurrentTimeSQL()
  3154.     {
  3155.         return 'CURRENT_TIME';
  3156.     }
  3157.     /**
  3158.      * Returns the SQL specific for the platform to get the current timestamp
  3159.      *
  3160.      * @return string
  3161.      */
  3162.     public function getCurrentTimestampSQL()
  3163.     {
  3164.         return 'CURRENT_TIMESTAMP';
  3165.     }
  3166.     /**
  3167.      * Returns the SQL for a given transaction isolation level Connection constant.
  3168.      *
  3169.      * @param int $level
  3170.      *
  3171.      * @return string
  3172.      *
  3173.      * @throws InvalidArgumentException
  3174.      */
  3175.     protected function _getTransactionIsolationLevelSQL($level)
  3176.     {
  3177.         switch ($level) {
  3178.             case TransactionIsolationLevel::READ_UNCOMMITTED:
  3179.                 return 'READ UNCOMMITTED';
  3180.             case TransactionIsolationLevel::READ_COMMITTED:
  3181.                 return 'READ COMMITTED';
  3182.             case TransactionIsolationLevel::REPEATABLE_READ:
  3183.                 return 'REPEATABLE READ';
  3184.             case TransactionIsolationLevel::SERIALIZABLE:
  3185.                 return 'SERIALIZABLE';
  3186.             default:
  3187.                 throw new InvalidArgumentException('Invalid isolation level:' $level);
  3188.         }
  3189.     }
  3190.     /**
  3191.      * @internal The method should be only used from within the {@see AbstractSchemaManager} class hierarchy.
  3192.      *
  3193.      * @return string
  3194.      *
  3195.      * @throws Exception If not supported on this platform.
  3196.      */
  3197.     public function getListDatabasesSQL()
  3198.     {
  3199.         throw Exception::notSupported(__METHOD__);
  3200.     }
  3201.     /**
  3202.      * Returns the SQL statement for retrieving the namespaces defined in the database.
  3203.      *
  3204.      * @deprecated Use {@see AbstractSchemaManager::listSchemaNames()} instead.
  3205.      *
  3206.      * @return string
  3207.      *
  3208.      * @throws Exception If not supported on this platform.
  3209.      */
  3210.     public function getListNamespacesSQL()
  3211.     {
  3212.         Deprecation::triggerIfCalledFromOutside(
  3213.             'doctrine/dbal',
  3214.             'https://github.com/doctrine/dbal/issues/4503',
  3215.             'AbstractPlatform::getListNamespacesSQL() is deprecated,'
  3216.                 ' use AbstractSchemaManager::listSchemaNames() instead.',
  3217.         );
  3218.         throw Exception::notSupported(__METHOD__);
  3219.     }
  3220.     /**
  3221.      * @internal The method should be only used from within the {@see AbstractSchemaManager} class hierarchy.
  3222.      *
  3223.      * @param string $database
  3224.      *
  3225.      * @return string
  3226.      *
  3227.      * @throws Exception If not supported on this platform.
  3228.      */
  3229.     public function getListSequencesSQL($database)
  3230.     {
  3231.         throw Exception::notSupported(__METHOD__);
  3232.     }
  3233.     /**
  3234.      * @deprecated
  3235.      *
  3236.      * @param string $table
  3237.      *
  3238.      * @return string
  3239.      *
  3240.      * @throws Exception If not supported on this platform.
  3241.      */
  3242.     public function getListTableConstraintsSQL($table)
  3243.     {
  3244.         throw Exception::notSupported(__METHOD__);
  3245.     }
  3246.     /**
  3247.      * @deprecated The SQL used for schema introspection is an implementation detail and should not be relied upon.
  3248.      *
  3249.      * @param string $table
  3250.      * @param string $database
  3251.      *
  3252.      * @return string
  3253.      *
  3254.      * @throws Exception If not supported on this platform.
  3255.      */
  3256.     public function getListTableColumnsSQL($table$database null)
  3257.     {
  3258.         throw Exception::notSupported(__METHOD__);
  3259.     }
  3260.     /**
  3261.      * @deprecated The SQL used for schema introspection is an implementation detail and should not be relied upon.
  3262.      *
  3263.      * @return string
  3264.      *
  3265.      * @throws Exception If not supported on this platform.
  3266.      */
  3267.     public function getListTablesSQL()
  3268.     {
  3269.         throw Exception::notSupported(__METHOD__);
  3270.     }
  3271.     /**
  3272.      * @deprecated
  3273.      *
  3274.      * @return string
  3275.      *
  3276.      * @throws Exception If not supported on this platform.
  3277.      */
  3278.     public function getListUsersSQL()
  3279.     {
  3280.         Deprecation::trigger(
  3281.             'doctrine/dbal',
  3282.             'https://github.com/doctrine/dbal/pull/4724',
  3283.             'AbstractPlatform::getListUsersSQL() is deprecated.',
  3284.         );
  3285.         throw Exception::notSupported(__METHOD__);
  3286.     }
  3287.     /**
  3288.      * Returns the SQL to list all views of a database or user.
  3289.      *
  3290.      * @internal The method should be only used from within the {@see AbstractSchemaManager} class hierarchy.
  3291.      *
  3292.      * @param string $database
  3293.      *
  3294.      * @return string
  3295.      *
  3296.      * @throws Exception If not supported on this platform.
  3297.      */
  3298.     public function getListViewsSQL($database)
  3299.     {
  3300.         throw Exception::notSupported(__METHOD__);
  3301.     }
  3302.     /**
  3303.      * @deprecated The SQL used for schema introspection is an implementation detail and should not be relied upon.
  3304.      *
  3305.      * Returns the list of indexes for the current database.
  3306.      *
  3307.      * The current database parameter is optional but will always be passed
  3308.      * when using the SchemaManager API and is the database the given table is in.
  3309.      *
  3310.      * Attention: Some platforms only support currentDatabase when they
  3311.      * are connected with that database. Cross-database information schema
  3312.      * requests may be impossible.
  3313.      *
  3314.      * @param string $table
  3315.      * @param string $database
  3316.      *
  3317.      * @return string
  3318.      *
  3319.      * @throws Exception If not supported on this platform.
  3320.      */
  3321.     public function getListTableIndexesSQL($table$database null)
  3322.     {
  3323.         throw Exception::notSupported(__METHOD__);
  3324.     }
  3325.     /**
  3326.      * @deprecated The SQL used for schema introspection is an implementation detail and should not be relied upon.
  3327.      *
  3328.      * @param string $table
  3329.      *
  3330.      * @return string
  3331.      *
  3332.      * @throws Exception If not supported on this platform.
  3333.      */
  3334.     public function getListTableForeignKeysSQL($table)
  3335.     {
  3336.         throw Exception::notSupported(__METHOD__);
  3337.     }
  3338.     /**
  3339.      * @param string $name
  3340.      * @param string $sql
  3341.      *
  3342.      * @return string
  3343.      */
  3344.     public function getCreateViewSQL($name$sql)
  3345.     {
  3346.         return 'CREATE VIEW ' $name ' AS ' $sql;
  3347.     }
  3348.     /**
  3349.      * @param string $name
  3350.      *
  3351.      * @return string
  3352.      */
  3353.     public function getDropViewSQL($name)
  3354.     {
  3355.         return 'DROP VIEW ' $name;
  3356.     }
  3357.     /**
  3358.      * @param string $sequence
  3359.      *
  3360.      * @return string
  3361.      *
  3362.      * @throws Exception If not supported on this platform.
  3363.      */
  3364.     public function getSequenceNextValSQL($sequence)
  3365.     {
  3366.         throw Exception::notSupported(__METHOD__);
  3367.     }
  3368.     /**
  3369.      * Returns the SQL to create a new database.
  3370.      *
  3371.      * @param string $name The name of the database that should be created.
  3372.      *
  3373.      * @return string
  3374.      *
  3375.      * @throws Exception If not supported on this platform.
  3376.      */
  3377.     public function getCreateDatabaseSQL($name)
  3378.     {
  3379.         if (! $this->supportsCreateDropDatabase()) {
  3380.             throw Exception::notSupported(__METHOD__);
  3381.         }
  3382.         return 'CREATE DATABASE ' $name;
  3383.     }
  3384.     /**
  3385.      * Returns the SQL snippet to drop an existing database.
  3386.      *
  3387.      * @param string $name The name of the database that should be dropped.
  3388.      *
  3389.      * @return string
  3390.      */
  3391.     public function getDropDatabaseSQL($name)
  3392.     {
  3393.         if (! $this->supportsCreateDropDatabase()) {
  3394.             throw Exception::notSupported(__METHOD__);
  3395.         }
  3396.         return 'DROP DATABASE ' $name;
  3397.     }
  3398.     /**
  3399.      * Returns the SQL to set the transaction isolation level.
  3400.      *
  3401.      * @param int $level
  3402.      *
  3403.      * @return string
  3404.      *
  3405.      * @throws Exception If not supported on this platform.
  3406.      */
  3407.     public function getSetTransactionIsolationSQL($level)
  3408.     {
  3409.         throw Exception::notSupported(__METHOD__);
  3410.     }
  3411.     /**
  3412.      * Obtains DBMS specific SQL to be used to create datetime columns in
  3413.      * statements like CREATE TABLE.
  3414.      *
  3415.      * @param mixed[] $column
  3416.      *
  3417.      * @return string
  3418.      *
  3419.      * @throws Exception If not supported on this platform.
  3420.      */
  3421.     public function getDateTimeTypeDeclarationSQL(array $column)
  3422.     {
  3423.         throw Exception::notSupported(__METHOD__);
  3424.     }
  3425.     /**
  3426.      * Obtains DBMS specific SQL to be used to create datetime with timezone offset columns.
  3427.      *
  3428.      * @param mixed[] $column
  3429.      *
  3430.      * @return string
  3431.      */
  3432.     public function getDateTimeTzTypeDeclarationSQL(array $column)
  3433.     {
  3434.         return $this->getDateTimeTypeDeclarationSQL($column);
  3435.     }
  3436.     /**
  3437.      * Obtains DBMS specific SQL to be used to create date columns in statements
  3438.      * like CREATE TABLE.
  3439.      *
  3440.      * @param mixed[] $column
  3441.      *
  3442.      * @return string
  3443.      *
  3444.      * @throws Exception If not supported on this platform.
  3445.      */
  3446.     public function getDateTypeDeclarationSQL(array $column)
  3447.     {
  3448.         throw Exception::notSupported(__METHOD__);
  3449.     }
  3450.     /**
  3451.      * Obtains DBMS specific SQL to be used to create time columns in statements
  3452.      * like CREATE TABLE.
  3453.      *
  3454.      * @param mixed[] $column
  3455.      *
  3456.      * @return string
  3457.      *
  3458.      * @throws Exception If not supported on this platform.
  3459.      */
  3460.     public function getTimeTypeDeclarationSQL(array $column)
  3461.     {
  3462.         throw Exception::notSupported(__METHOD__);
  3463.     }
  3464.     /**
  3465.      * @param mixed[] $column
  3466.      *
  3467.      * @return string
  3468.      */
  3469.     public function getFloatDeclarationSQL(array $column)
  3470.     {
  3471.         return 'DOUBLE PRECISION';
  3472.     }
  3473.     /**
  3474.      * Gets the default transaction isolation level of the platform.
  3475.      *
  3476.      * @see TransactionIsolationLevel
  3477.      *
  3478.      * @return TransactionIsolationLevel::* The default isolation level.
  3479.      */
  3480.     public function getDefaultTransactionIsolationLevel()
  3481.     {
  3482.         return TransactionIsolationLevel::READ_COMMITTED;
  3483.     }
  3484.     /* supports*() methods */
  3485.     /**
  3486.      * Whether the platform supports sequences.
  3487.      *
  3488.      * @return bool
  3489.      */
  3490.     public function supportsSequences()
  3491.     {
  3492.         return false;
  3493.     }
  3494.     /**
  3495.      * Whether the platform supports identity columns.
  3496.      *
  3497.      * Identity columns are columns that receive an auto-generated value from the
  3498.      * database on insert of a row.
  3499.      *
  3500.      * @return bool
  3501.      */
  3502.     public function supportsIdentityColumns()
  3503.     {
  3504.         return false;
  3505.     }
  3506.     /**
  3507.      * Whether the platform emulates identity columns through sequences.
  3508.      *
  3509.      * Some platforms that do not support identity columns natively
  3510.      * but support sequences can emulate identity columns by using
  3511.      * sequences.
  3512.      *
  3513.      * @deprecated
  3514.      *
  3515.      * @return bool
  3516.      */
  3517.     public function usesSequenceEmulatedIdentityColumns()
  3518.     {
  3519.         Deprecation::trigger(
  3520.             'doctrine/dbal',
  3521.             'https://github.com/doctrine/dbal/pull/5513',
  3522.             '%s is deprecated.',
  3523.             __METHOD__,
  3524.         );
  3525.         return false;
  3526.     }
  3527.     /**
  3528.      * Returns the name of the sequence for a particular identity column in a particular table.
  3529.      *
  3530.      * @deprecated
  3531.      *
  3532.      * @see usesSequenceEmulatedIdentityColumns
  3533.      *
  3534.      * @param string $tableName  The name of the table to return the sequence name for.
  3535.      * @param string $columnName The name of the identity column in the table to return the sequence name for.
  3536.      *
  3537.      * @return string
  3538.      *
  3539.      * @throws Exception If not supported on this platform.
  3540.      */
  3541.     public function getIdentitySequenceName($tableName$columnName)
  3542.     {
  3543.         throw Exception::notSupported(__METHOD__);
  3544.     }
  3545.     /**
  3546.      * Whether the platform supports indexes.
  3547.      *
  3548.      * @deprecated
  3549.      *
  3550.      * @return bool
  3551.      */
  3552.     public function supportsIndexes()
  3553.     {
  3554.         Deprecation::trigger(
  3555.             'doctrine/dbal',
  3556.             'https://github.com/doctrine/dbal/pull/4724',
  3557.             'AbstractPlatform::supportsIndexes() is deprecated.',
  3558.         );
  3559.         return true;
  3560.     }
  3561.     /**
  3562.      * Whether the platform supports partial indexes.
  3563.      *
  3564.      * @return bool
  3565.      */
  3566.     public function supportsPartialIndexes()
  3567.     {
  3568.         return false;
  3569.     }
  3570.     /**
  3571.      * Whether the platform supports indexes with column length definitions.
  3572.      */
  3573.     public function supportsColumnLengthIndexes(): bool
  3574.     {
  3575.         return false;
  3576.     }
  3577.     /**
  3578.      * Whether the platform supports altering tables.
  3579.      *
  3580.      * @deprecated All platforms must implement altering tables.
  3581.      *
  3582.      * @return bool
  3583.      */
  3584.     public function supportsAlterTable()
  3585.     {
  3586.         Deprecation::trigger(
  3587.             'doctrine/dbal',
  3588.             'https://github.com/doctrine/dbal/pull/4724',
  3589.             'AbstractPlatform::supportsAlterTable() is deprecated. All platforms must implement altering tables.',
  3590.         );
  3591.         return true;
  3592.     }
  3593.     /**
  3594.      * Whether the platform supports transactions.
  3595.      *
  3596.      * @deprecated
  3597.      *
  3598.      * @return bool
  3599.      */
  3600.     public function supportsTransactions()
  3601.     {
  3602.         Deprecation::trigger(
  3603.             'doctrine/dbal',
  3604.             'https://github.com/doctrine/dbal/pull/4724',
  3605.             'AbstractPlatform::supportsTransactions() is deprecated.',
  3606.         );
  3607.         return true;
  3608.     }
  3609.     /**
  3610.      * Whether the platform supports savepoints.
  3611.      *
  3612.      * @return bool
  3613.      */
  3614.     public function supportsSavepoints()
  3615.     {
  3616.         return true;
  3617.     }
  3618.     /**
  3619.      * Whether the platform supports releasing savepoints.
  3620.      *
  3621.      * @return bool
  3622.      */
  3623.     public function supportsReleaseSavepoints()
  3624.     {
  3625.         return $this->supportsSavepoints();
  3626.     }
  3627.     /**
  3628.      * Whether the platform supports primary key constraints.
  3629.      *
  3630.      * @deprecated
  3631.      *
  3632.      * @return bool
  3633.      */
  3634.     public function supportsPrimaryConstraints()
  3635.     {
  3636.         Deprecation::trigger(
  3637.             'doctrine/dbal',
  3638.             'https://github.com/doctrine/dbal/pull/4724',
  3639.             'AbstractPlatform::supportsPrimaryConstraints() is deprecated.',
  3640.         );
  3641.         return true;
  3642.     }
  3643.     /**
  3644.      * Whether the platform supports foreign key constraints.
  3645.      *
  3646.      * @deprecated All platforms should support foreign key constraints.
  3647.      *
  3648.      * @return bool
  3649.      */
  3650.     public function supportsForeignKeyConstraints()
  3651.     {
  3652.         Deprecation::triggerIfCalledFromOutside(
  3653.             'doctrine/dbal',
  3654.             'https://github.com/doctrine/dbal/pull/5409',
  3655.             'AbstractPlatform::supportsForeignKeyConstraints() is deprecated.',
  3656.         );
  3657.         return true;
  3658.     }
  3659.     /**
  3660.      * Whether the platform supports database schemas.
  3661.      *
  3662.      * @return bool
  3663.      */
  3664.     public function supportsSchemas()
  3665.     {
  3666.         return false;
  3667.     }
  3668.     /**
  3669.      * Whether this platform can emulate schemas.
  3670.      *
  3671.      * @deprecated
  3672.      *
  3673.      * Platforms that either support or emulate schemas don't automatically
  3674.      * filter a schema for the namespaced elements in {@see AbstractManager::introspectSchema()}.
  3675.      *
  3676.      * @return bool
  3677.      */
  3678.     public function canEmulateSchemas()
  3679.     {
  3680.         Deprecation::trigger(
  3681.             'doctrine/dbal',
  3682.             'https://github.com/doctrine/dbal/pull/4805',
  3683.             'AbstractPlatform::canEmulateSchemas() is deprecated.',
  3684.         );
  3685.         return false;
  3686.     }
  3687.     /**
  3688.      * Returns the default schema name.
  3689.      *
  3690.      * @deprecated
  3691.      *
  3692.      * @return string
  3693.      *
  3694.      * @throws Exception If not supported on this platform.
  3695.      */
  3696.     public function getDefaultSchemaName()
  3697.     {
  3698.         throw Exception::notSupported(__METHOD__);
  3699.     }
  3700.     /**
  3701.      * Whether this platform supports create database.
  3702.      *
  3703.      * Some databases don't allow to create and drop databases at all or only with certain tools.
  3704.      *
  3705.      * @deprecated
  3706.      *
  3707.      * @return bool
  3708.      */
  3709.     public function supportsCreateDropDatabase()
  3710.     {
  3711.         Deprecation::triggerIfCalledFromOutside(
  3712.             'doctrine/dbal',
  3713.             'https://github.com/doctrine/dbal/pull/5513',
  3714.             '%s is deprecated.',
  3715.             __METHOD__,
  3716.         );
  3717.         return true;
  3718.     }
  3719.     /**
  3720.      * Whether the platform supports getting the affected rows of a recent update/delete type query.
  3721.      *
  3722.      * @deprecated
  3723.      *
  3724.      * @return bool
  3725.      */
  3726.     public function supportsGettingAffectedRows()
  3727.     {
  3728.         Deprecation::trigger(
  3729.             'doctrine/dbal',
  3730.             'https://github.com/doctrine/dbal/pull/4724',
  3731.             'AbstractPlatform::supportsGettingAffectedRows() is deprecated.',
  3732.         );
  3733.         return true;
  3734.     }
  3735.     /**
  3736.      * Whether this platform support to add inline column comments as postfix.
  3737.      *
  3738.      * @return bool
  3739.      */
  3740.     public function supportsInlineColumnComments()
  3741.     {
  3742.         return false;
  3743.     }
  3744.     /**
  3745.      * Whether this platform support the proprietary syntax "COMMENT ON asset".
  3746.      *
  3747.      * @return bool
  3748.      */
  3749.     public function supportsCommentOnStatement()
  3750.     {
  3751.         return false;
  3752.     }
  3753.     /**
  3754.      * Does this platform have native guid type.
  3755.      *
  3756.      * @deprecated
  3757.      *
  3758.      * @return bool
  3759.      */
  3760.     public function hasNativeGuidType()
  3761.     {
  3762.         Deprecation::triggerIfCalledFromOutside(
  3763.             'doctrine/dbal',
  3764.             'https://github.com/doctrine/dbal/pull/5509',
  3765.             '%s is deprecated.',
  3766.             __METHOD__,
  3767.         );
  3768.         return false;
  3769.     }
  3770.     /**
  3771.      * Does this platform have native JSON type.
  3772.      *
  3773.      * @deprecated
  3774.      *
  3775.      * @return bool
  3776.      */
  3777.     public function hasNativeJsonType()
  3778.     {
  3779.         Deprecation::triggerIfCalledFromOutside(
  3780.             'doctrine/dbal',
  3781.             'https://github.com/doctrine/dbal/pull/5509',
  3782.             '%s is deprecated.',
  3783.             __METHOD__,
  3784.         );
  3785.         return false;
  3786.     }
  3787.     /**
  3788.      * Whether this platform supports views.
  3789.      *
  3790.      * @deprecated All platforms must implement support for views.
  3791.      *
  3792.      * @return bool
  3793.      */
  3794.     public function supportsViews()
  3795.     {
  3796.         Deprecation::trigger(
  3797.             'doctrine/dbal',
  3798.             'https://github.com/doctrine/dbal/pull/4724',
  3799.             'AbstractPlatform::supportsViews() is deprecated. All platforms must implement support for views.',
  3800.         );
  3801.         return true;
  3802.     }
  3803.     /**
  3804.      * Does this platform support column collation?
  3805.      *
  3806.      * @return bool
  3807.      */
  3808.     public function supportsColumnCollation()
  3809.     {
  3810.         return false;
  3811.     }
  3812.     /**
  3813.      * Gets the format string, as accepted by the date() function, that describes
  3814.      * the format of a stored datetime value of this platform.
  3815.      *
  3816.      * @return string The format string.
  3817.      */
  3818.     public function getDateTimeFormatString()
  3819.     {
  3820.         return 'Y-m-d H:i:s';
  3821.     }
  3822.     /**
  3823.      * Gets the format string, as accepted by the date() function, that describes
  3824.      * the format of a stored datetime with timezone value of this platform.
  3825.      *
  3826.      * @return string The format string.
  3827.      */
  3828.     public function getDateTimeTzFormatString()
  3829.     {
  3830.         return 'Y-m-d H:i:s';
  3831.     }
  3832.     /**
  3833.      * Gets the format string, as accepted by the date() function, that describes
  3834.      * the format of a stored date value of this platform.
  3835.      *
  3836.      * @return string The format string.
  3837.      */
  3838.     public function getDateFormatString()
  3839.     {
  3840.         return 'Y-m-d';
  3841.     }
  3842.     /**
  3843.      * Gets the format string, as accepted by the date() function, that describes
  3844.      * the format of a stored time value of this platform.
  3845.      *
  3846.      * @return string The format string.
  3847.      */
  3848.     public function getTimeFormatString()
  3849.     {
  3850.         return 'H:i:s';
  3851.     }
  3852.     /**
  3853.      * Adds an driver-specific LIMIT clause to the query.
  3854.      *
  3855.      * @param string   $query
  3856.      * @param int|null $limit
  3857.      * @param int      $offset
  3858.      *
  3859.      * @throws Exception
  3860.      */
  3861.     final public function modifyLimitQuery($query$limit$offset 0): string
  3862.     {
  3863.         if ($offset 0) {
  3864.             throw new Exception(sprintf(
  3865.                 'Offset must be a positive integer or zero, %d given',
  3866.                 $offset,
  3867.             ));
  3868.         }
  3869.         if ($offset && ! $this->supportsLimitOffset()) {
  3870.             throw new Exception(sprintf(
  3871.                 'Platform %s does not support offset values in limit queries.',
  3872.                 $this->getName(),
  3873.             ));
  3874.         }
  3875.         if ($limit !== null) {
  3876.             $limit = (int) $limit;
  3877.         }
  3878.         return $this->doModifyLimitQuery($query$limit, (int) $offset);
  3879.     }
  3880.     /**
  3881.      * Adds an platform-specific LIMIT clause to the query.
  3882.      *
  3883.      * @param string   $query
  3884.      * @param int|null $limit
  3885.      * @param int      $offset
  3886.      *
  3887.      * @return string
  3888.      */
  3889.     protected function doModifyLimitQuery($query$limit$offset)
  3890.     {
  3891.         if ($limit !== null) {
  3892.             $query .= sprintf(' LIMIT %d'$limit);
  3893.         }
  3894.         if ($offset 0) {
  3895.             $query .= sprintf(' OFFSET %d'$offset);
  3896.         }
  3897.         return $query;
  3898.     }
  3899.     /**
  3900.      * Whether the database platform support offsets in modify limit clauses.
  3901.      *
  3902.      * @deprecated All platforms must implement support for offsets in modify limit clauses.
  3903.      *
  3904.      * @return bool
  3905.      */
  3906.     public function supportsLimitOffset()
  3907.     {
  3908.         Deprecation::triggerIfCalledFromOutside(
  3909.             'doctrine/dbal',
  3910.             'https://github.com/doctrine/dbal/pull/4724',
  3911.             'AbstractPlatform::supportsViews() is deprecated.'
  3912.             ' All platforms must implement support for offsets in modify limit clauses.',
  3913.         );
  3914.         return true;
  3915.     }
  3916.     /**
  3917.      * Maximum length of any given database identifier, like tables or column names.
  3918.      *
  3919.      * @return int
  3920.      */
  3921.     public function getMaxIdentifierLength()
  3922.     {
  3923.         return 63;
  3924.     }
  3925.     /**
  3926.      * Returns the insert SQL for an empty insert statement.
  3927.      *
  3928.      * @param string $quotedTableName
  3929.      * @param string $quotedIdentifierColumnName
  3930.      *
  3931.      * @return string
  3932.      */
  3933.     public function getEmptyIdentityInsertSQL($quotedTableName$quotedIdentifierColumnName)
  3934.     {
  3935.         return 'INSERT INTO ' $quotedTableName ' (' $quotedIdentifierColumnName ') VALUES (null)';
  3936.     }
  3937.     /**
  3938.      * Generates a Truncate Table SQL statement for a given table.
  3939.      *
  3940.      * Cascade is not supported on many platforms but would optionally cascade the truncate by
  3941.      * following the foreign keys.
  3942.      *
  3943.      * @param string $tableName
  3944.      * @param bool   $cascade
  3945.      *
  3946.      * @return string
  3947.      */
  3948.     public function getTruncateTableSQL($tableName$cascade false)
  3949.     {
  3950.         $tableIdentifier = new Identifier($tableName);
  3951.         return 'TRUNCATE ' $tableIdentifier->getQuotedName($this);
  3952.     }
  3953.     /**
  3954.      * This is for test reasons, many vendors have special requirements for dummy statements.
  3955.      *
  3956.      * @return string
  3957.      */
  3958.     public function getDummySelectSQL()
  3959.     {
  3960.         $expression func_num_args() > func_get_arg(0) : '1';
  3961.         return sprintf('SELECT %s'$expression);
  3962.     }
  3963.     /**
  3964.      * Returns the SQL to create a new savepoint.
  3965.      *
  3966.      * @param string $savepoint
  3967.      *
  3968.      * @return string
  3969.      */
  3970.     public function createSavePoint($savepoint)
  3971.     {
  3972.         return 'SAVEPOINT ' $savepoint;
  3973.     }
  3974.     /**
  3975.      * Returns the SQL to release a savepoint.
  3976.      *
  3977.      * @param string $savepoint
  3978.      *
  3979.      * @return string
  3980.      */
  3981.     public function releaseSavePoint($savepoint)
  3982.     {
  3983.         return 'RELEASE SAVEPOINT ' $savepoint;
  3984.     }
  3985.     /**
  3986.      * Returns the SQL to rollback a savepoint.
  3987.      *
  3988.      * @param string $savepoint
  3989.      *
  3990.      * @return string
  3991.      */
  3992.     public function rollbackSavePoint($savepoint)
  3993.     {
  3994.         return 'ROLLBACK TO SAVEPOINT ' $savepoint;
  3995.     }
  3996.     /**
  3997.      * Returns the keyword list instance of this platform.
  3998.      *
  3999.      * @throws Exception If no keyword list is specified.
  4000.      */
  4001.     final public function getReservedKeywordsList(): KeywordList
  4002.     {
  4003.         // Store the instance so it doesn't need to be generated on every request.
  4004.         return $this->_keywords ??= $this->createReservedKeywordsList();
  4005.     }
  4006.     /**
  4007.      * Creates an instance of the reserved keyword list of this platform.
  4008.      *
  4009.      * This method will become @abstract in DBAL 4.0.0.
  4010.      *
  4011.      * @throws Exception
  4012.      */
  4013.     protected function createReservedKeywordsList(): KeywordList
  4014.     {
  4015.         $class    $this->getReservedKeywordsClass();
  4016.         $keywords = new $class();
  4017.         if (! $keywords instanceof KeywordList) {
  4018.             throw Exception::notSupported(__METHOD__);
  4019.         }
  4020.         return $keywords;
  4021.     }
  4022.     /**
  4023.      * Returns the class name of the reserved keywords list.
  4024.      *
  4025.      * @deprecated Implement {@see createReservedKeywordsList()} instead.
  4026.      *
  4027.      * @return string
  4028.      * @psalm-return class-string<KeywordList>
  4029.      *
  4030.      * @throws Exception If not supported on this platform.
  4031.      */
  4032.     protected function getReservedKeywordsClass()
  4033.     {
  4034.         Deprecation::triggerIfCalledFromOutside(
  4035.             'doctrine/dbal',
  4036.             'https://github.com/doctrine/dbal/issues/4510',
  4037.             'AbstractPlatform::getReservedKeywordsClass() is deprecated,'
  4038.                 ' use AbstractPlatform::createReservedKeywordsList() instead.',
  4039.         );
  4040.         throw Exception::notSupported(__METHOD__);
  4041.     }
  4042.     /**
  4043.      * Quotes a literal string.
  4044.      * This method is NOT meant to fix SQL injections!
  4045.      * It is only meant to escape this platform's string literal
  4046.      * quote character inside the given literal string.
  4047.      *
  4048.      * @param string $str The literal string to be quoted.
  4049.      *
  4050.      * @return string The quoted literal string.
  4051.      */
  4052.     public function quoteStringLiteral($str)
  4053.     {
  4054.         $c $this->getStringLiteralQuoteCharacter();
  4055.         return $c str_replace($c$c $c$str) . $c;
  4056.     }
  4057.     /**
  4058.      * Gets the character used for string literal quoting.
  4059.      *
  4060.      * @deprecated Use {@see quoteStringLiteral()} to quote string literals instead.
  4061.      *
  4062.      * @return string
  4063.      */
  4064.     public function getStringLiteralQuoteCharacter()
  4065.     {
  4066.         Deprecation::triggerIfCalledFromOutside(
  4067.             'doctrine/dbal',
  4068.             'https://github.com/doctrine/dbal/pull/5388',
  4069.             'AbstractPlatform::getStringLiteralQuoteCharacter() is deprecated.'
  4070.                 ' Use quoteStringLiteral() instead.',
  4071.         );
  4072.         return "'";
  4073.     }
  4074.     /**
  4075.      * Escapes metacharacters in a string intended to be used with a LIKE
  4076.      * operator.
  4077.      *
  4078.      * @param string $inputString a literal, unquoted string
  4079.      * @param string $escapeChar  should be reused by the caller in the LIKE
  4080.      *                            expression.
  4081.      */
  4082.     final public function escapeStringForLike(string $inputStringstring $escapeChar): string
  4083.     {
  4084.         return preg_replace(
  4085.             '~([' preg_quote($this->getLikeWildcardCharacters() . $escapeChar'~') . '])~u',
  4086.             addcslashes($escapeChar'\\') . '$1',
  4087.             $inputString,
  4088.         );
  4089.     }
  4090.     /**
  4091.      * @return array<string,mixed> An associative array with the name of the properties
  4092.      *                             of the column being declared as array indexes.
  4093.      */
  4094.     private function columnToArray(Column $column): array
  4095.     {
  4096.         $name $column->getQuotedName($this);
  4097.         return array_merge($column->toArray(), [
  4098.             'name' => $name,
  4099.             'version' => $column->hasPlatformOption('version') ? $column->getPlatformOption('version') : false,
  4100.             'comment' => $this->getColumnComment($column),
  4101.         ]);
  4102.     }
  4103.     /** @internal */
  4104.     public function createSQLParser(): Parser
  4105.     {
  4106.         return new Parser(false);
  4107.     }
  4108.     protected function getLikeWildcardCharacters(): string
  4109.     {
  4110.         return '%_';
  4111.     }
  4112.     /**
  4113.      * Compares the definitions of the given columns in the context of this platform.
  4114.      *
  4115.      * @throws Exception
  4116.      */
  4117.     public function columnsEqual(Column $column1Column $column2): bool
  4118.     {
  4119.         $column1Array $this->columnToArray($column1);
  4120.         $column2Array $this->columnToArray($column2);
  4121.         // ignore explicit columnDefinition since it's not set on the Column generated by the SchemaManager
  4122.         unset($column1Array['columnDefinition']);
  4123.         unset($column2Array['columnDefinition']);
  4124.         if (
  4125.             $this->getColumnDeclarationSQL(''$column1Array)
  4126.             !== $this->getColumnDeclarationSQL(''$column2Array)
  4127.         ) {
  4128.             return false;
  4129.         }
  4130.         if (! $this->columnDeclarationsMatch($column1$column2)) {
  4131.             return false;
  4132.         }
  4133.         // If the platform supports inline comments, all comparison is already done above
  4134.         if ($this->supportsInlineColumnComments()) {
  4135.             return true;
  4136.         }
  4137.         if ($column1->getComment() !== $column2->getComment()) {
  4138.             return false;
  4139.         }
  4140.         return $column1->getType() === $column2->getType();
  4141.     }
  4142.     /**
  4143.      * Whether the database data type matches that expected for the doctrine type for the given colunms.
  4144.      */
  4145.     private function columnDeclarationsMatch(Column $column1Column $column2): bool
  4146.     {
  4147.         return ! (
  4148.             $column1->hasPlatformOption('declarationMismatch') ||
  4149.             $column2->hasPlatformOption('declarationMismatch')
  4150.         );
  4151.     }
  4152.     /**
  4153.      * Creates the schema manager that can be used to inspect and change the underlying
  4154.      * database schema according to the dialect of the platform.
  4155.      *
  4156.      * @throws Exception
  4157.      *
  4158.      * @abstract
  4159.      */
  4160.     public function createSchemaManager(Connection $connection): AbstractSchemaManager
  4161.     {
  4162.         throw Exception::notSupported(__METHOD__);
  4163.     }
  4164. }