[2.0] DDC-313 - Removed lots of dead and unnecessary code
This commit is contained in:
parent
5b43f72e27
commit
b9daf621cf
@ -1314,28 +1314,6 @@ abstract class AbstractPlatform
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* build a pattern matching string
|
||||
*
|
||||
* EXPERIMENTAL
|
||||
*
|
||||
* WARNING: this function is experimental and may change signature at
|
||||
* any time until labelled as non-experimental
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $pattern even keys are strings, odd are patterns (% and _)
|
||||
* @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future)
|
||||
* @param string $field optional field name that is being matched against
|
||||
* (might be required when emulating ILIKE)
|
||||
*
|
||||
* @return string SQL pattern
|
||||
*/
|
||||
public function getMatchPatternExpression($pattern, $operator = null, $field = null)
|
||||
{
|
||||
throw DBALException::notSupported(__METHOD__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the platform prefers sequences for ID generation.
|
||||
* Subclasses should override this method to return TRUE if they prefer sequences.
|
||||
@ -1530,19 +1508,6 @@ abstract class AbstractPlatform
|
||||
throw DBALException::notSupported(__METHOD__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $charset name of the charset
|
||||
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration.
|
||||
*/
|
||||
public function getCharsetFieldDeclaration($charset)
|
||||
{
|
||||
throw DBALException::notSupported(__METHOD__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL to be used to create datetime fields in
|
||||
* statements like CREATE TABLE
|
||||
|
@ -32,17 +32,10 @@ use Doctrine\Common\DoctrineException;
|
||||
* @since 2.0
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Jonathan H. Wage <jonwage@gmail.com>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class MsSqlPlatform extends AbstractPlatform
|
||||
{
|
||||
/**
|
||||
* the constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
{
|
||||
/**
|
||||
* Adds an adapter-specific LIMIT clause to the SELECT statement.
|
||||
* [ borrowed from Zend Framework ]
|
||||
@ -144,16 +137,6 @@ class MsSqlPlatform extends AbstractPlatform
|
||||
return 'RLIKE';
|
||||
}
|
||||
|
||||
/**
|
||||
* return string to call a function to get random value inside an SQL statement
|
||||
*
|
||||
* @return string to generate float between 0 and 1
|
||||
*/
|
||||
public function getRandomExpression()
|
||||
{
|
||||
return 'RAND()';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return string to call a variable with the current timestamp inside an SQL statement
|
||||
* There are three special variables for current date and time:
|
||||
@ -351,19 +334,6 @@ class MsSqlPlatform extends AbstractPlatform
|
||||
return $unsigned . $autoinc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $charset name of the charset
|
||||
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration.
|
||||
*/
|
||||
public function getCharsetFieldDeclaration($charset)
|
||||
{
|
||||
return 'CHARACTER SET ' . $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
|
@ -31,17 +31,10 @@ use Doctrine\Common\DoctrineException,
|
||||
*
|
||||
* @since 2.0
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class MySqlPlatform extends AbstractPlatform
|
||||
{
|
||||
/**
|
||||
* Creates a new MySqlPlatform instance.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
{
|
||||
/**
|
||||
* Gets the character used for identifier quoting.
|
||||
*
|
||||
@ -64,65 +57,6 @@ class MySqlPlatform extends AbstractPlatform
|
||||
return 'RLIKE';
|
||||
}
|
||||
|
||||
/**
|
||||
* return string to call a function to get random value inside an SQL statement
|
||||
*
|
||||
* @return string to generate float between 0 and 1
|
||||
*/
|
||||
public function getRandomExpression()
|
||||
{
|
||||
return 'RAND()';
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a pattern matching string.
|
||||
*
|
||||
* EXPERIMENTAL
|
||||
*
|
||||
* WARNING: this function is experimental and may change signature at
|
||||
* any time until labelled as non-experimental.
|
||||
*
|
||||
* @param array $pattern even keys are strings, odd are patterns (% and _)
|
||||
* @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future)
|
||||
* @param string $field optional field name that is being matched against
|
||||
* (might be required when emulating ILIKE)
|
||||
*
|
||||
* @return string SQL pattern
|
||||
* @override
|
||||
*/
|
||||
public function getMatchPatternExpression($pattern, $operator = null, $field = null)
|
||||
{
|
||||
$match = '';
|
||||
if ( ! is_null($operator)) {
|
||||
$field = is_null($field) ? '' : $field.' ';
|
||||
$operator = strtoupper($operator);
|
||||
switch ($operator) {
|
||||
// case insensitive
|
||||
case 'ILIKE':
|
||||
$match = $field.'LIKE ';
|
||||
break;
|
||||
// case sensitive
|
||||
case 'LIKE':
|
||||
$match = $field.'LIKE BINARY ';
|
||||
break;
|
||||
default:
|
||||
throw DoctrineException::operatorNotSupported($operator);
|
||||
}
|
||||
}
|
||||
$match.= "'";
|
||||
foreach ($pattern as $key => $value) {
|
||||
if ($key % 2) {
|
||||
$match .= $value;
|
||||
} else {
|
||||
$match .= $this->conn->escapePattern($this->conn->escape($value));
|
||||
}
|
||||
}
|
||||
$match.= "'";
|
||||
$match.= $this->patternEscapeString();
|
||||
|
||||
return $match;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns global unique identifier
|
||||
*
|
||||
@ -235,19 +169,6 @@ class MySqlPlatform extends AbstractPlatform
|
||||
return 'LONGTEXT';
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $charset name of the charset
|
||||
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration.
|
||||
*/
|
||||
public function getCharsetFieldDeclaration($charset)
|
||||
{
|
||||
return 'CHARACTER SET ' . $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
|
@ -33,14 +33,6 @@ use Doctrine\DBAL\Schema\TableDiff;
|
||||
*/
|
||||
class OraclePlatform extends AbstractPlatform
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* return string to call a function to get a substring inside an SQL statement
|
||||
*
|
||||
@ -82,17 +74,6 @@ class OraclePlatform extends AbstractPlatform
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* random
|
||||
*
|
||||
* @return string an oracle SQL string that generates a float between 0 and 1
|
||||
* @override
|
||||
*/
|
||||
public function getRandomExpression()
|
||||
{
|
||||
return 'dbms_random.value';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns global unique identifier
|
||||
*
|
||||
|
@ -33,44 +33,6 @@ use Doctrine\DBAL\Schema\TableDiff;
|
||||
*/
|
||||
class PostgreSqlPlatform extends AbstractPlatform
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
* Creates a new PostgreSqlPlatform.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the md5 sum of a field.
|
||||
*
|
||||
* Note: Not SQL92, but common functionality
|
||||
*
|
||||
* md5() works with the default PostgreSQL 8 versions.
|
||||
*
|
||||
* If you are using PostgreSQL 7.x or older you need
|
||||
* to make sure that the digest procedure is installed.
|
||||
* If you use RPMS (Redhat and Mandrake) install the postgresql-contrib
|
||||
* package. You must then install the procedure by running this shell command:
|
||||
* <code>
|
||||
* psql [dbname] < /usr/share/pgsql/contrib/pgcrypto.sql
|
||||
* </code>
|
||||
* You should make sure you run this as the postgres user.
|
||||
*
|
||||
* @return string
|
||||
* @override
|
||||
*/
|
||||
public function getMd5Expression($column)
|
||||
{
|
||||
if ($this->_version > 7) {
|
||||
return 'MD5(' . $column . ')';
|
||||
} else {
|
||||
return 'encode(digest(' . $column .', md5), hex)';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns part of a string.
|
||||
*
|
||||
@ -91,45 +53,6 @@ class PostgreSqlPlatform extends AbstractPlatform
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PostgreSQLs AGE(<timestamp1> [, <timestamp2>]) function.
|
||||
*
|
||||
* @param string $timestamp1 timestamp to subtract from NOW()
|
||||
* @param string $timestamp2 optional; if given: subtract arguments
|
||||
* @return string
|
||||
*/
|
||||
public function getAgeExpression($timestamp1, $timestamp2 = null)
|
||||
{
|
||||
if ( $timestamp2 == null ) {
|
||||
return 'AGE(' . $timestamp1 . ')';
|
||||
}
|
||||
return 'AGE(' . $timestamp1 . ', ' . $timestamp2 . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* PostgreSQLs DATE_PART( <text>, <time> ) function.
|
||||
*
|
||||
* @param string $text what to extract
|
||||
* @param string $time timestamp or interval to extract from
|
||||
* @return string
|
||||
*/
|
||||
public function getDatePartExpression($text, $time)
|
||||
{
|
||||
return 'DATE_PART(' . $text . ', ' . $time . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* PostgreSQLs TO_CHAR( <time>, <text> ) function.
|
||||
*
|
||||
* @param string $time timestamp or interval
|
||||
* @param string $text how to the format the output
|
||||
* @return string
|
||||
*/
|
||||
public function getToCharExpression($time, $text)
|
||||
{
|
||||
return 'TO_CHAR(' . $time . ', ' . $text . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SQL string to return the current system date and time.
|
||||
*
|
||||
@ -150,69 +73,6 @@ class PostgreSqlPlatform extends AbstractPlatform
|
||||
{
|
||||
return 'SIMILAR TO';
|
||||
}
|
||||
|
||||
/**
|
||||
* return string to call a function to get random value inside an SQL statement
|
||||
*
|
||||
* @return return string to generate float between 0 and 1
|
||||
* @access public
|
||||
* @override
|
||||
*/
|
||||
public function getRandomExpression()
|
||||
{
|
||||
return 'RANDOM()';
|
||||
}
|
||||
|
||||
/**
|
||||
* build a pattern matching string
|
||||
*
|
||||
* EXPERIMENTAL
|
||||
*
|
||||
* WARNING: this function is experimental and may change signature at
|
||||
* any time until labelled as non-experimental
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $pattern even keys are strings, odd are patterns (% and _)
|
||||
* @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future)
|
||||
* @param string $field optional field name that is being matched against
|
||||
* (might be required when emulating ILIKE)
|
||||
*
|
||||
* @return string SQL pattern
|
||||
* @override
|
||||
*/
|
||||
public function getMatchPatternExpression($pattern, $operator = null, $field = null)
|
||||
{
|
||||
$match = '';
|
||||
if ( ! is_null($operator)) {
|
||||
$field = is_null($field) ? '' : $field.' ';
|
||||
$operator = strtoupper($operator);
|
||||
switch ($operator) {
|
||||
// case insensitive
|
||||
case 'ILIKE':
|
||||
$match = $field.'ILIKE ';
|
||||
break;
|
||||
// case sensitive
|
||||
case 'LIKE':
|
||||
$match = $field.'LIKE ';
|
||||
break;
|
||||
default:
|
||||
throw DoctrineException::operatorNotSupported($operator);
|
||||
}
|
||||
}
|
||||
$match.= "'";
|
||||
foreach ($pattern as $key => $value) {
|
||||
if ($key % 2) {
|
||||
$match.= $value;
|
||||
} else {
|
||||
$match.= $this->conn->escapePattern($this->conn->escape($value));
|
||||
}
|
||||
}
|
||||
$match.= "'";
|
||||
$match.= $this->patternEscapeString();
|
||||
|
||||
return $match;
|
||||
}
|
||||
|
||||
/**
|
||||
* parses a literal boolean value and returns
|
||||
|
@ -29,74 +29,10 @@ use Doctrine\Common\DoctrineException;
|
||||
*
|
||||
* @since 2.0
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
* @author Benjamin Eberlei <kontakt@beberlei.de>
|
||||
*/
|
||||
class SqlitePlatform extends AbstractPlatform
|
||||
{
|
||||
/**
|
||||
* the constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the md5 sum of the data that SQLite's md5() function receives.
|
||||
*
|
||||
* @param mixed $data
|
||||
* @return string
|
||||
*/
|
||||
public static function md5Impl($data)
|
||||
{
|
||||
return md5($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the modules of the data that SQLite's mod() function receives.
|
||||
*
|
||||
* @param integer $dividend
|
||||
* @param integer $divisor
|
||||
* @return string
|
||||
*/
|
||||
public static function modImpl($dividend, $divisor)
|
||||
{
|
||||
return $dividend % $divisor;
|
||||
}
|
||||
|
||||
/**
|
||||
* locate
|
||||
* returns the position of the first occurrence of substring $substr in string $str that
|
||||
* SQLite's locate() function receives
|
||||
*
|
||||
* @param string $substr literal string to find
|
||||
* @param string $str literal string
|
||||
* @return string
|
||||
*/
|
||||
public static function locateImpl($substr, $str)
|
||||
{
|
||||
return strpos($str, $substr);
|
||||
}
|
||||
|
||||
public static function sha1Impl($str)
|
||||
{
|
||||
return sha1($str);
|
||||
}
|
||||
|
||||
public static function ltrimImpl($str)
|
||||
{
|
||||
return ltrim($str);
|
||||
}
|
||||
|
||||
public static function rtrimImpl($str)
|
||||
{
|
||||
return rtrim($str);
|
||||
}
|
||||
|
||||
public static function trimImpl($str)
|
||||
{
|
||||
return trim($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the regular expression operator
|
||||
*
|
||||
@ -108,20 +44,6 @@ class SqlitePlatform extends AbstractPlatform
|
||||
return 'RLIKE';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string to call a function to compute the
|
||||
* soundex encoding of a string
|
||||
*
|
||||
* The string "?000" is returned if the argument is NULL.
|
||||
*
|
||||
* @param string $value
|
||||
* @return string SQL soundex function with given parameter
|
||||
*/
|
||||
public function getSoundexExpression($value)
|
||||
{
|
||||
return 'SOUNDEX(' . $value . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return string to call a variable with the current timestamp inside an SQL statement
|
||||
* There are three special variables for current date and time.
|
||||
@ -142,17 +64,6 @@ class SqlitePlatform extends AbstractPlatform
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* return string to call a function to get random value inside an SQL statement
|
||||
*
|
||||
* @return string to generate float between 0 and 1
|
||||
* @override
|
||||
*/
|
||||
public function getRandomExpression()
|
||||
{
|
||||
return '((RANDOM() + 2147483648) / 4294967296)';
|
||||
}
|
||||
|
||||
/**
|
||||
* return string to call a function to get a substring inside an SQL statement
|
||||
*
|
||||
@ -377,11 +288,6 @@ class SqlitePlatform extends AbstractPlatform
|
||||
return 'CLOB';
|
||||
}
|
||||
|
||||
public function getListSequencesSql($database)
|
||||
{
|
||||
return "SELECT name FROM sqlite_master WHERE type='table' AND sql NOT NULL ORDER BY name";
|
||||
}
|
||||
|
||||
public function getListTableConstraintsSql($table)
|
||||
{
|
||||
return "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = '$table' AND sql NOT NULL ORDER BY name";
|
||||
@ -437,11 +343,6 @@ class SqlitePlatform extends AbstractPlatform
|
||||
return false;
|
||||
}
|
||||
|
||||
public function supportsSequences()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the platform name for this instance
|
||||
*
|
||||
|
@ -37,9 +37,7 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
|
||||
{
|
||||
$this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
|
||||
$this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
|
||||
$this->assertEquals('RAND()', $this->_platform->getRandomExpression(), 'Random function is not correct');
|
||||
$this->assertEquals('(column1 + column2 + column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
|
||||
$this->assertEquals('CHARACTER SET utf8', $this->_platform->getCharsetFieldDeclaration('utf8'), 'Charset declaration is not correct');
|
||||
}
|
||||
|
||||
public function testGeneratesTransactionsCommands()
|
||||
|
@ -46,9 +46,7 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
|
||||
{
|
||||
$this->assertEquals('RLIKE', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
|
||||
$this->assertEquals('`', $this->_platform->getIdentifierQuoteCharacter(), 'Quote character is not correct');
|
||||
$this->assertEquals('RAND()', $this->_platform->getRandomExpression(), 'Random function is not correct');
|
||||
$this->assertEquals('CONCAT(column1, column2, column3)', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation function is not correct');
|
||||
$this->assertEquals('CHARACTER SET utf8', $this->_platform->getCharsetFieldDeclaration('utf8'), 'Charset declaration is not correct');
|
||||
}
|
||||
|
||||
public function testGeneratesTransactionsCommands()
|
||||
|
@ -48,18 +48,9 @@ class OraclePlatformTest extends AbstractPlatformTestCase
|
||||
public function testGeneratesSqlSnippets()
|
||||
{
|
||||
$this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
|
||||
$this->assertEquals('dbms_random.value', $this->_platform->getRandomExpression(), 'Random function is not correct');
|
||||
$this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Doctrine\DBAL\DBALException
|
||||
*/
|
||||
public function testGetCharsetFieldDeclaration()
|
||||
{
|
||||
$this->assertEquals('CHARACTER SET utf8', $this->_platform->getCharsetFieldDeclaration('utf8'), 'Charset declaration is not correct');
|
||||
}
|
||||
|
||||
public function testGeneratesTransactionsCommands()
|
||||
{
|
||||
$this->assertEquals(
|
||||
|
@ -65,7 +65,6 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
|
||||
{
|
||||
$this->assertEquals('SIMILAR TO', $this->_platform->getRegexpExpression(), 'Regular expression operator is not correct');
|
||||
$this->assertEquals('"', $this->_platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct');
|
||||
$this->assertEquals('RANDOM()', $this->_platform->getRandomExpression(), 'Random function is not correct');
|
||||
$this->assertEquals('column1 || column2 || column3', $this->_platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct');
|
||||
$this->assertEquals('SUBSTR(column, 5)', $this->_platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct');
|
||||
$this->assertEquals('SUBSTR(column, 0, 5)', $this->_platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct');
|
||||
|
Loading…
x
Reference in New Issue
Block a user