Commit 4d437439 authored by guilhermeblanco's avatar guilhermeblanco

[2.0] Added boolean type support

parent a65ea05f
......@@ -769,6 +769,14 @@ abstract class AbstractPlatform
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.
*
......@@ -1543,11 +1551,6 @@ abstract class AbstractPlatform
*/
abstract public function getVarcharTypeDeclarationSql(array $field);
public function getBooleanTypeDeclarationSql(array $field)
{
return $this->getIntegerTypeDeclarationSql($field);
}
/**
* Gets the name of the platform.
*
......
......@@ -324,19 +324,34 @@ class MsSqlPlatform extends AbstractPlatform
{
return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSql($level);
}
/**
* @override
*/
public function getBooleanTypeDeclarationSql(array $field)
{
return 'BIT';
}
/**
* @override
*/
public function getIntegerTypeDeclarationSql(array $field)
{
return 'INT' . $this->_getCommonIntegerTypeDeclarationSql($field);
}
/** @override */
/**
* @override
*/
public function getBigIntTypeDeclarationSql(array $field)
{
return 'BIGINT' . $this->_getCommonIntegerTypeDeclarationSql($field);
}
/** @override */
/**
* @override
*/
public function getSmallIntTypeDeclarationSql(array $field)
{
return 'SMALLINT' . $this->_getCommonIntegerTypeDeclarationSql($field);
......
......@@ -152,6 +152,14 @@ class OraclePlatform extends AbstractPlatform
return parent::_getTransactionIsolationLevelSql($level);
}
}
/**
* @override
*/
public function getBooleanTypeDeclarationSql(array $field)
{
return 'NUMBER(1)';
}
/**
* @override
......
......@@ -218,10 +218,10 @@ class PostgreSqlPlatform extends AbstractPlatform
* @param string $value boolean value to be parsed
* @return string parsed boolean value
*/
public function parseBoolean($value)
/*public function parseBoolean($value)
{
return $value;
}
}*/
/**
* Whether the platform supports sequences.
......@@ -656,6 +656,14 @@ class PostgreSqlPlatform extends AbstractPlatform
return 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL '
. $this->_getTransactionIsolationLevelSql($level);
}
/**
* @override
*/
public function getBooleanTypeDeclarationSql(array $field)
{
return 'BOOLEAN';
}
/**
* @override
......@@ -665,6 +673,7 @@ class PostgreSqlPlatform extends AbstractPlatform
if ( ! empty($field['autoincrement'])) {
return 'SERIAL';
}
return 'INT';
}
......
......@@ -193,43 +193,65 @@ class SqlitePlatform extends AbstractPlatform
return 'PRAGMA read_uncommitted = ' . $this->_getTransactionIsolationLevelSql($level);
}
/** @override */
/**
* @override
*/
public function prefersIdentityColumns()
{
return true;
}
/**
* @override
*/
public function getBooleanTypeDeclarationSql(array $field)
{
return 'BOOLEAN';
}
/** @override */
/**
* @override
*/
public function getIntegerTypeDeclarationSql(array $field)
{
return $this->_getCommonIntegerTypeDeclarationSql($field);
}
/** @override */
/**
* @override
*/
public function getBigIntTypeDeclarationSql(array $field)
{
return $this->_getCommonIntegerTypeDeclarationSql($field);
}
/** @override */
/**
* @override
*/
public function getTinyIntTypeDeclarationSql(array $field)
{
return $this->_getCommonIntegerTypeDeclarationSql($field);
}
/** @override */
/**
* @override
*/
public function getSmallIntTypeDeclarationSql(array $field)
{
return $this->_getCommonIntegerTypeDeclarationSql($field);
}
/** @override */
/**
* @override
*/
public function getMediumIntTypeDeclarationSql(array $field)
{
return $this->_getCommonIntegerTypeDeclarationSql($field);
}
/** @override */
/**
* @override
*/
public function getDateTimeTypeDeclarationSql(array $fieldDeclaration)
{
return 'DATETIME';
......@@ -243,7 +265,9 @@ class SqlitePlatform extends AbstractPlatform
return 'DATE';
}
/** @override */
/**
* @override
*/
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef)
{
$autoinc = ! empty($columnDef['autoincrement']) ? ' AUTOINCREMENT' : '';
......
......@@ -13,7 +13,7 @@ class BooleanType extends Type
{
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return $platform->getBooleanDeclarationSql();
return $platform->getBooleanTypeDeclarationSql($fieldDeclaration);
}
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