Commit 4d437439 authored by guilhermeblanco's avatar guilhermeblanco

[2.0] Added boolean type support

parent a65ea05f
...@@ -769,6 +769,14 @@ abstract class AbstractPlatform ...@@ -769,6 +769,14 @@ abstract class AbstractPlatform
return 'NUMERIC(' . $columnDef['precision'] . ', ' . $columnDef['scale'] . ')'; return 'NUMERIC(' . $columnDef['precision'] . ', ' . $columnDef['scale'] . ')';
} }
/**
* Gets the SQL snippet that declares a boolean column.
*
* @param array $columnDef
* @return string
*/
abstract public function getBooleanTypeDeclarationSql(array $columnDef);
/** /**
* Gets the SQL snippet that declares a 4 byte integer column. * Gets the SQL snippet that declares a 4 byte integer column.
* *
...@@ -1543,11 +1551,6 @@ abstract class AbstractPlatform ...@@ -1543,11 +1551,6 @@ abstract class AbstractPlatform
*/ */
abstract public function getVarcharTypeDeclarationSql(array $field); abstract public function getVarcharTypeDeclarationSql(array $field);
public function getBooleanTypeDeclarationSql(array $field)
{
return $this->getIntegerTypeDeclarationSql($field);
}
/** /**
* Gets the name of the platform. * Gets the name of the platform.
* *
......
...@@ -325,18 +325,33 @@ class MsSqlPlatform extends AbstractPlatform ...@@ -325,18 +325,33 @@ class MsSqlPlatform extends AbstractPlatform
return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSql($level); return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSql($level);
} }
/**
* @override
*/
public function getBooleanTypeDeclarationSql(array $field)
{
return 'BIT';
}
/**
* @override
*/
public function getIntegerTypeDeclarationSql(array $field) public function getIntegerTypeDeclarationSql(array $field)
{ {
return 'INT' . $this->_getCommonIntegerTypeDeclarationSql($field); return 'INT' . $this->_getCommonIntegerTypeDeclarationSql($field);
} }
/** @override */ /**
* @override
*/
public function getBigIntTypeDeclarationSql(array $field) public function getBigIntTypeDeclarationSql(array $field)
{ {
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSql($field); return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSql($field);
} }
/** @override */ /**
* @override
*/
public function getSmallIntTypeDeclarationSql(array $field) public function getSmallIntTypeDeclarationSql(array $field)
{ {
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSql($field); return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSql($field);
......
...@@ -153,6 +153,14 @@ class OraclePlatform extends AbstractPlatform ...@@ -153,6 +153,14 @@ class OraclePlatform extends AbstractPlatform
} }
} }
/**
* @override
*/
public function getBooleanTypeDeclarationSql(array $field)
{
return 'NUMBER(1)';
}
/** /**
* @override * @override
*/ */
......
...@@ -218,10 +218,10 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -218,10 +218,10 @@ class PostgreSqlPlatform extends AbstractPlatform
* @param string $value boolean value to be parsed * @param string $value boolean value to be parsed
* @return string parsed boolean value * @return string parsed boolean value
*/ */
public function parseBoolean($value) /*public function parseBoolean($value)
{ {
return $value; return $value;
} }*/
/** /**
* Whether the platform supports sequences. * Whether the platform supports sequences.
...@@ -657,6 +657,14 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -657,6 +657,14 @@ class PostgreSqlPlatform extends AbstractPlatform
. $this->_getTransactionIsolationLevelSql($level); . $this->_getTransactionIsolationLevelSql($level);
} }
/**
* @override
*/
public function getBooleanTypeDeclarationSql(array $field)
{
return 'BOOLEAN';
}
/** /**
* @override * @override
*/ */
...@@ -665,6 +673,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -665,6 +673,7 @@ class PostgreSqlPlatform extends AbstractPlatform
if ( ! empty($field['autoincrement'])) { if ( ! empty($field['autoincrement'])) {
return 'SERIAL'; return 'SERIAL';
} }
return 'INT'; return 'INT';
} }
......
...@@ -193,43 +193,65 @@ class SqlitePlatform extends AbstractPlatform ...@@ -193,43 +193,65 @@ class SqlitePlatform extends AbstractPlatform
return 'PRAGMA read_uncommitted = ' . $this->_getTransactionIsolationLevelSql($level); return 'PRAGMA read_uncommitted = ' . $this->_getTransactionIsolationLevelSql($level);
} }
/** @override */ /**
* @override
*/
public function prefersIdentityColumns() public function prefersIdentityColumns()
{ {
return true; return true;
} }
/** @override */ /**
* @override
*/
public function getBooleanTypeDeclarationSql(array $field)
{
return 'BOOLEAN';
}
/**
* @override
*/
public function getIntegerTypeDeclarationSql(array $field) public function getIntegerTypeDeclarationSql(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSql($field);
} }
/** @override */ /**
* @override
*/
public function getBigIntTypeDeclarationSql(array $field) public function getBigIntTypeDeclarationSql(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSql($field);
} }
/** @override */ /**
* @override
*/
public function getTinyIntTypeDeclarationSql(array $field) public function getTinyIntTypeDeclarationSql(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSql($field);
} }
/** @override */ /**
* @override
*/
public function getSmallIntTypeDeclarationSql(array $field) public function getSmallIntTypeDeclarationSql(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSql($field);
} }
/** @override */ /**
* @override
*/
public function getMediumIntTypeDeclarationSql(array $field) public function getMediumIntTypeDeclarationSql(array $field)
{ {
return $this->_getCommonIntegerTypeDeclarationSql($field); return $this->_getCommonIntegerTypeDeclarationSql($field);
} }
/** @override */ /**
* @override
*/
public function getDateTimeTypeDeclarationSql(array $fieldDeclaration) public function getDateTimeTypeDeclarationSql(array $fieldDeclaration)
{ {
return 'DATETIME'; return 'DATETIME';
...@@ -243,7 +265,9 @@ class SqlitePlatform extends AbstractPlatform ...@@ -243,7 +265,9 @@ class SqlitePlatform extends AbstractPlatform
return 'DATE'; return 'DATE';
} }
/** @override */ /**
* @override
*/
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef) protected function _getCommonIntegerTypeDeclarationSql(array $columnDef)
{ {
$autoinc = ! empty($columnDef['autoincrement']) ? ' AUTOINCREMENT' : ''; $autoinc = ! empty($columnDef['autoincrement']) ? ' AUTOINCREMENT' : '';
......
...@@ -13,7 +13,7 @@ class BooleanType extends Type ...@@ -13,7 +13,7 @@ class BooleanType extends Type
{ {
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{ {
return $platform->getBooleanDeclarationSql(); return $platform->getBooleanTypeDeclarationSql($fieldDeclaration);
} }
public function convertToDatabaseValue($value, AbstractPlatform $platform) public function convertToDatabaseValue($value, AbstractPlatform $platform)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment