1
0
mirror of synced 2025-01-31 04:21:44 +03:00

[2.0] Added boolean type support

This commit is contained in:
guilhermeblanco 2009-09-05 02:23:24 +00:00
parent a65ea05f01
commit 4d4374395b
6 changed files with 77 additions and 18 deletions

View File

@ -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.
*

View File

@ -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);

View File

@ -152,6 +152,14 @@ class OraclePlatform extends AbstractPlatform
return parent::_getTransactionIsolationLevelSql($level);
}
}
/**
* @override
*/
public function getBooleanTypeDeclarationSql(array $field)
{
return 'NUMBER(1)';
}
/**
* @override

View File

@ -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';
}

View File

@ -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' : '';

View File

@ -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)