8000 [DBAL-1082] Fix SchemaTool does not generate SQL for MySQL unsigned float by dchesterton · Pull Request #749 · doctrine/dbal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[DBAL-1082] Fix SchemaTool does not generate SQL for MySQL unsigned float #749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/en/reference/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+---------+----------------------------------------------------------+
| | | **SQLite** | *all* | ``INTEGER`` [16]_ |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **decimal** [7]_ | ``string`` | **MySQL** | *all* | ``NUMERIC(p, s)`` |
| | [9]_ +--------------------------+ | |
| | | **PostgreSQL** | | |
| **decimal** [7]_ | ``string`` | **MySQL** | *all* | ``NUMERIC(p, s)`` ``UNSIGNED`` [10]_ |
| | [9]_ +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``NUMERIC(p, s)`` |
| | +--------------------------+ | |
| | | **Oracle** | | |
| | +--------------------------+ | |
Expand All @@ -483,9 +483,9 @@ Please also notice the mapping specific footnotes for additional information.
| | +--------------------------+ | |
| | | **Drizzle** | | |
+-------------------+---------------+--------------------------+---------+----------------------------------------------------------+
| **float** | ``float`` | **MySQL** | *all* | ``DOUBLE PRECISION`` |
| | +--------------------------+ | |
| | | **PostgreSQL** | | |
| **float** | ``float`` | **MySQL** | *all* 8000 | ``DOUBLE PRECISION`` ``UNSIGNED`` [10]_ |
| | +--------------------------+---------+----------------------------------------------------------+
| | | **PostgreSQL** | *all* | ``DOUBLE PRECISION`` |
| | +--------------------------+ | |
| | | **Oracle** | | |
| | +--------------------------+ | |
Expand Down
32 changes: 30 additions & 2 deletions lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,35 @@ public function getSmallIntTypeDeclarationSQL(array $field)
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSQL($field);
}

/**
* {@inheritdoc}
*/
public function getFloatDeclarationSQL(array $field)
{
return 'DOUBLE PRECISION' . $this->getUnsignedDeclaration($field);
}

/**
* {@inheritdoc}
*/
public function getDecimalTypeDeclarationSQL(array $columnDef)
{
$declaration = parent::getDecimalTypeDeclarationSQL($columnDef);
return $declaration . $this->getUnsignedDeclaration($columnDef);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can make this a one liner

}

/**
* Get unsigned declaration for a column.
*
* @param array $columnDef
*
* @return string
*/
private function getUnsignedDeclaration(array $columnDef)
{
return ! empty($columnDef['unsigned']) ? ' UNSIGNED' : '';
}

/**
* {@inheritDoc}
*/
Expand All @@ -722,9 +751,8 @@ protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
if ( ! empty($columnDef['autoincrement'])) {
$autoinc = ' AUTO_INCREMENT';
}
$unsigned = (isset($columnDef['unsigned']) && $columnDef['unsigned']) ? ' UNSIGNED' : '';

return $unsigned . $autoinc;
return $this->getUnsignedDeclaration($columnDef) . $autoinc;
}

/**
Expand Down
0