Commit 705199e8 authored by romanb's avatar romanb

[2.0] Parser work. Added support for functions in SelectExpressions.

parent 5ebaa650
......@@ -16,7 +16,7 @@
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.org>.
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Platforms;
......@@ -185,7 +185,7 @@ class MySqlPlatform extends AbstractPlatform
$match = $field.'LIKE BINARY ';
break;
default:
throw \Doctrine\Common\DoctrineException::updateMe('not a supported operator type:'. $operator);
throw DoctrineException::updateMe('not a supported operator type:'. $operator);
}
}
$match.= "'";
......@@ -520,7 +520,7 @@ class MySqlPlatform extends AbstractPlatform
$length = null;
break;
default:
throw \Doctrine\Common\DoctrineException::updateMe('unknown database attribute type: ' . $dbType);
throw DoctrineException::updateMe('unknown database attribute type: ' . $dbType);
}
$length = ((int) $length == 0) ? null : (int) $length;
......@@ -678,10 +678,10 @@ class MySqlPlatform extends AbstractPlatform
public function getCreateTableSql($name, array $fields, array $options = array())
{
if ( ! $name) {
throw \Doctrine\Common\DoctrineException::updateMe('no valid table name specified');
throw DoctrineException::updateMe('no valid table name specified');
}
if (empty($fields)) {
throw \Doctrine\Common\DoctrineException::updateMe('no fields specified for table "'.$name.'"');
throw DoctrineException::updateMe('no fields specified for table "'.$name.'"');
}
$queryFields = $this->getFieldDeclarationListSql($fields);
......@@ -866,7 +866,7 @@ class MySqlPlatform extends AbstractPlatform
public function getAlterTableSql($name, array $changes, $check = false)
{
if ( ! $name) {
throw \Doctrine\Common\DoctrineException::updateMe('no valid table name specified');
throw DoctrineException::updateMe('no valid table name specified');
}
foreach ($changes as $changeName => $change) {
switch ($changeName) {
......@@ -877,7 +877,7 @@ class MySqlPlatform extends AbstractPlatform
case 'name':
break;
default:
throw \Doctrine\Common\DoctrineException::updateMe('change type "' . $changeName . '" not yet supported');
throw DoctrineException::updateMe('change type "' . $changeName . '" not yet supported');
}
}
......@@ -1003,7 +1003,7 @@ class MySqlPlatform extends AbstractPlatform
$type = strtoupper($definition['type']) . ' ';
break;
default:
throw \Doctrine\Common\DoctrineException::updateMe('Unknown index type ' . $definition['type']);
throw DoctrineException::updateMe('Unknown index type ' . $definition['type']);
}
}
$query = 'CREATE ' . $type . 'INDEX ' . $name . ' ON ' . $table;
......@@ -1050,10 +1050,10 @@ class MySqlPlatform extends AbstractPlatform
}
/** @override */
public function getTinyIntTypeDeclarationSql(array $field)
/*public function getTinyIntTypeDeclarationSql(array $field)
{
return 'TINYINT' . $this->_getCommonIntegerTypeDeclarationSql($field);
}
}*/
/** @override */
public function getSmallIntTypeDeclarationSql(array $field)
......@@ -1062,10 +1062,10 @@ class MySqlPlatform extends AbstractPlatform
}
/** @override */
public function getMediumIntTypeDeclarationSql(array $field)
/*public function getMediumIntTypeDeclarationSql(array $field)
{
return 'MEDIUMINT' . $this->_getCommonIntegerTypeDeclarationSql($field);
}
}*/
/** @override */
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef)
......
......@@ -101,7 +101,7 @@ class PostgreSqlPlatform extends AbstractPlatform
public function getNativeDeclaration(array $field)
{
if ( ! isset($field['type'])) {
throw \Doctrine\Common\DoctrineException::updateMe('Missing column type.');
throw DoctrineException::updateMe('Missing column type.');
}
switch ($field['type']) {
case 'char':
......@@ -161,7 +161,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'NUMERIC('.$length.','.$scale.')';
}
throw \Doctrine\Common\DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
throw DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
}
/**
......@@ -293,7 +293,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$length = null;
break;
default:
throw \Doctrine\Common\DoctrineException::updateMe('unknown database attribute type: '.$dbType);
throw DoctrineException::updateMe('unknown database attribute type: '.$dbType);
}
return array('type' => $type,
......@@ -461,7 +461,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$match = $field.'LIKE ';
break;
default:
throw \Doctrine\Common\DoctrineException::updateMe('not a supported operator type:'. $operator);
throw DoctrineException::updateMe('not a supported operator type:'. $operator);
}
}
$match.= "'";
......@@ -766,7 +766,7 @@ class PostgreSqlPlatform extends AbstractPlatform
case 'rename':
break;
default:
throw \Doctrine\Common\DoctrineException::updateMe('change type "' . $changeName . '\" not yet supported');
throw DoctrineException::updateMe('change type "' . $changeName . '\" not yet supported');
}
}
......@@ -798,7 +798,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$serverInfo = $this->getServerVersion();
if (is_array($serverInfo) && $serverInfo['major'] < 8) {
throw \Doctrine\Common\DoctrineException::updateMe('changing column type for "'.$field['type'].'\" requires PostgreSQL 8.0 or above');
throw DoctrineException::updateMe('changing column type for "'.$field['type'].'\" requires PostgreSQL 8.0 or above');
}
$query = 'ALTER ' . $fieldName . ' TYPE ' . $this->getTypeDeclarationSql($field['definition']);
$sql[] = 'ALTER TABLE ' . $name . ' ' . $query;
......@@ -875,10 +875,10 @@ class PostgreSqlPlatform extends AbstractPlatform
public function getCreateTableSql($name, array $fields, array $options = array())
{
if ( ! $name) {
throw \Doctrine\Common\DoctrineException::updateMe('no valid table name specified');
throw DoctrineException::updateMe('no valid table name specified');
}
if (empty($fields)) {
throw \Doctrine\Common\DoctrineException::updateMe('no fields specified for table ' . $name);
throw DoctrineException::updateMe('no fields specified for table ' . $name);
}
$queryFields = $this->getFieldDeclarationListSql($fields);
......@@ -1001,4 +1001,65 @@ class PostgreSqlPlatform extends AbstractPlatform
return 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL '
. $this->_getTransactionIsolationLevelSql($level);
}
/**
* @override
*/
public function getIntegerTypeDeclarationSql(array $field)
{
if ( ! empty($field['autoincrement'])) {
return 'SERIAL';
}
return 'INT';
}
/**
* @override
*/
public function getBigIntTypeDeclarationSql(array $field)
{
if ( ! empty($field['autoincrement'])) {
return 'BIGSERIAL';
}
return 'BIGINT';
}
/**
* @override
*/
public function getSmallIntTypeDeclarationSql(array $field)
{
return 'SMALLINT';
}
/**
* @override
*/
protected function _getCommonIntegerTypeDeclarationSql(array $columnDef)
{
return '';
}
/**
* Gets the SQL snippet used to declare a VARCHAR column on the MySql platform.
*
* @params array $field
* @override
*/
public function getVarcharDeclarationSql(array $field)
{
if ( ! isset($field['length'])) {
if (array_key_exists('default', $field)) {
$field['length'] = $this->getVarcharMaxLength();
} else {
$field['length'] = false;
}
}
$length = ($field['length'] <= $this->getVarcharMaxLength()) ? $field['length'] : false;
$fixed = (isset($field['fixed'])) ? $field['fixed'] : false;
return $fixed ? ($length ? 'CHAR(' . $length . ')' : 'CHAR(255)')
: ($length ? 'VARCHAR(' . $length . ')' : 'TEXT');
}
}
\ No newline at end of file
......@@ -194,7 +194,7 @@ class SqlitePlatform extends AbstractPlatform
public function getNativeDeclaration(array $field)
{
if ( ! isset($field['type'])) {
throw \Doctrine\Common\DoctrineException::updateMe('Missing column type.');
throw DoctrineException::updateMe('Missing column type.');
}
switch ($field['type']) {
case 'text':
......@@ -254,7 +254,7 @@ class SqlitePlatform extends AbstractPlatform
$scale = !empty($field['scale']) ? $field['scale'] : $this->conn->getAttribute(Doctrine::ATTR_DECIMAL_PLACES);
return 'DECIMAL('.$length.','.$scale.')';
}
throw \Doctrine\Common\DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
throw DoctrineException::updateMe('Unknown field type \'' . $field['type'] . '\'.');
}
/**
......@@ -371,7 +371,7 @@ class SqlitePlatform extends AbstractPlatform
$length = null;
break;
default:
throw \Doctrine\Common\DoctrineException::updateMe('unknown database attribute type: '.$dbType);
throw DoctrineException::updateMe('unknown database attribute type: '.$dbType);
}
return array('type' => $type,
......
<?php
namespace Doctrine\DBAL\Types;
/**
* Description of MediumIntType
*
* @author robo
*/
class MediumIntType
{
//put your code here
}
\ No newline at end of file
<?php
namespace Doctrine\DBAL\Types;
/**
* Description of TinyIntType
*
* @author robo
*/
class TinyIntType
{
//put your code here
}
\ No newline at end of file
......@@ -22,7 +22,7 @@
namespace Doctrine\ORM;
/**
* Doctrine_EntityManager_Exception
* EntityManagerException
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
......
......@@ -31,13 +31,18 @@ class ConcatFunction extends FunctionNode
*/
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
//TODO: Use platform to get SQL
$platform = $sqlWalker->getConnection()->getDatabasePlatform();
return $platform->getConcatExpression(
$sqlWalker->walkStringPrimary($this->_firstStringPrimary),
$sqlWalker->walkStringPrimary($this->_secondStringPrimary)
);
/*
$sql = 'CONCAT(' .
$sqlWalker->walkStringPrimary($this->_firstStringPrimary)
. ', ' .
$sqlWalker->walkStringPrimary($this->_secondStringPrimary)
. ')';
return $sql;
return $sql;*/
}
/**
......
......@@ -50,17 +50,5 @@ abstract class FunctionNode extends Node
return $sqlWalker->walkFunction($this);
}
//abstract public function parse(\Doctrine\ORM\Query\Parser $parser);
/*
public function getExpressions()
{
return $this->_expressions;
}
public function setExpressions(array $expressions)
{
$this->_expressions = $expressions;
}
*/
abstract public function parse(\Doctrine\ORM\Query\Parser $parser);
}
\ No newline at end of file
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
namespace Doctrine\ORM\Query\AST;
/**
* QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"
*
* @author robo
*/
class QuantifiedExpression extends Node
{
private $_all;
private $_any;
private $_some;
private $_subselect;
public function __construct($subselect)
{
$this->_subselect = $subselect;
}
public function getSubselect()
{
return $this->_subselect;
}
public function isAll()
{
return $this->_all;
}
public function isAny()
{
return $this->_any;
}
public function isSome()
{
return $this->_some;
}
public function setAll($bool)
{
$this->_all = $bool;
}
public function setAny($bool)
{
$this->_any = $bool;
}
public function setSome($bool)
{
$this->_some = $bool;
}
/**
* @override
*/
public function dispatch($sqlWalker)
{
return $sqlWalker->walkQuantifiedExpression($this);
}
}
......@@ -336,7 +336,7 @@ class Lexer
}
/**
* @todo Doc
* Resets the peek pointer to 0.
*/
public function resetPeek()
{
......@@ -351,6 +351,12 @@ class Lexer
$this->_position = $position;
}
/**
* Gets the literal for a given token.
*
* @param mixed $token
* @return string
*/
public function getLiteral($token)
{
if ( ! $this->_keywordsTable) {
......
......@@ -626,7 +626,8 @@ class Parser
/**
* SelectExpression ::=
* IdentificationVariable | StateFieldPathExpression |
* (AggregateExpression | "(" Subselect ")") [["AS"] FieldAliasIdentificationVariable]
* (AggregateExpression | "(" Subselect ")") [["AS"] FieldAliasIdentificationVariable] |
* Function
*/
public function _SelectExpression()
{
......@@ -634,11 +635,15 @@ class Parser
$fieldIdentificationVariable = null;
$peek = $this->_lexer->glimpse();
// First we recognize for an IdentificationVariable (DQL class alias)
if ($peek['value'] != '.' && $this->_lexer->lookahead['type'] === Lexer::T_IDENTIFIER) {
if ($peek['value'] != '.' && $peek['value'] != '(' && $this->_lexer->lookahead['type'] === Lexer::T_IDENTIFIER) {
$expression = $this->_IdentificationVariable();
} else if (($isFunction = $this->_isFunction()) !== false || $this->_isSubselect()) {
if ($isFunction) {
$expression = $this->_AggregateExpression();
if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
$expression = $this->_AggregateExpression();
} else {
$expression = $this->_Function();
}
} else {
$this->match('(');
$expression = $this->_Subselect();
......@@ -1290,7 +1295,7 @@ class Parser
}
}
}
else if ($this->_isAggregateFunction($this->_lexer->lookahead)) {
/*else if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
$leftExpr = $this->_StringExpression();
$operator = $this->_ComparisonOperator();
if ($this->_lexer->lookahead['type'] === Lexer::T_ALL ||
......@@ -1300,7 +1305,7 @@ class Parser
} else {
$rightExpr = $this->_StringExpression();
}
}
}*/
else {
$leftExpr = $this->_ArithmeticExpression();
$operator = $this->_ComparisonOperator();
......@@ -1316,6 +1321,20 @@ class Parser
return new AST\ComparisonExpression($leftExpr, $operator, $rightExpr);
}
public function _Function()
{
$funcName = $this->_lexer->lookahead['value'];
if ($this->_isStringFunction($funcName)) {
return $this->_FunctionsReturningStrings();
} else if ($this->_isNumericFunction($funcName)) {
return $this->_FunctionsReturningNumerics();
} else if ($this->_isDatetimeFunction($funcName)) {
return $this->_FunctionsReturningDatetime();
} else {
$this->syntaxError('Known function.');
}
}
public function _isStringFunction($funcName)
{
return isset(self::$_STRING_FUNCTIONS[strtolower($funcName)]);
......@@ -1468,6 +1487,33 @@ class Parser
return $existsExpression;
}
/**
* QuantifiedExpression ::= ("ALL" | "ANY" | "SOME") "(" Subselect ")"
*/
public function _QuantifiedExpression()
{
$all = $any = $some = false;
if ($this->_lexer->isNextToken(Lexer::T_ALL)) {
$this->match(Lexer::T_ALL);
$all = true;
} else if ($this->_lexer->isNextToken(Lexer::T_ANY)) {
$this->match(Lexer::T_ANY);
$any = true;
} else if ($this->_lexer->isNextToken(Lexer::T_SOME)) {
$this->match(Lexer::T_SOME);
$some = true;
} else {
$this->syntaxError('ALL, ANY or SOME');
}
$this->match('(');
$qExpr = new AST\QuantifiedExpression($this->_Subselect());
$this->match(')');
$qExpr->setAll($all);
$qExpr->setAny($any);
$qExpr->setSome($some);
return $qExpr;
}
/**
* Subselect ::= SimpleSelectClause SubselectFromClause [WhereClause] [GroupByClause] [HavingClause] [OrderByClause]
*/
......@@ -1805,7 +1851,7 @@ class Parser
if ($peek['value'] == '.') {
return $this->_StateFieldPathExpression();
} else if ($peek['value'] == '(') {
//TODO... FunctionsReturningStrings or AggregateExpression
return $this->_FunctionsReturningStrings();
} else {
$this->syntaxError("'.' or '('");
}
......@@ -1815,6 +1861,8 @@ class Parser
} else if ($this->_lexer->lookahead['type'] === Lexer::T_INPUT_PARAMETER) {
$this->match(Lexer::T_INPUT_PARAMETER);
return new AST\InputParameter($this->_lexer->token['value']);
} else if ($this->_isAggregateFunction($this->_lexer->lookahead['type'])) {
return $this->_AggregateExpression();
} else {
$this->syntaxError('StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression');
}
......
This diff is collapsed.
......@@ -89,7 +89,7 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
public function testFunctionalExpressionsSupportedInWherePart()
{
//$this->assertValidDql("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'");
$this->assertValidDql("SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'");
}
public function testArithmeticExpressionsSupportedInWherePart()
......@@ -300,29 +300,23 @@ class LanguageRecognitionTest extends \Doctrine\Tests\OrmTestCase
$this->assertValidDql("SELECT u, a FROM Doctrine\Tests\Models\CMS\CmsUser u, Doctrine\Tests\Models\CMS\CmsArticle a WHERE u.name = a.topic");
}
/*
public function testCustomJoinsAndWithKeywordSupported()
public function testAllExpressionWithCorrelatedSubquery()
{
// We need existant classes here, otherwise semantical will always fail
$this->assertValidDql('SELECT c.*, c2.*, d.* FROM Record_Country c INNER JOIN c.City c2 WITH c2.id = 2 WHERE c.id = 1');
$this->assertValidDql('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ALL (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
}
*/
/* public function testAllExpressionWithCorrelatedSubquery()
public function testCustomJoinsAndWithKeywordSupported()
{
// We need existant classes here, otherwise semantical will always fail
$this->assertValidDql('SELECT * FROM CompanyEmployee e WHERE e.salary > ALL (SELECT m.salary FROM CompanyManager m WHERE m.department = e.department)', true);
$this->assertValidDql('SELECT u, p FROM Doctrine\Tests\Models\CMS\CmsUser u INNER JOIN u.phonenumbers p WITH p.phonenumber = 123 WHERE u.id = 1');
}
public function testAnyExpressionWithCorrelatedSubquery()
{
// We need existant classes here, otherwise semantical will always fail
$this->assertValidDql('SELECT * FROM Employee e WHERE e.salary > ANY (SELECT m.salary FROM Manager m WHERE m.department = e.department)');
$this->assertValidDql('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > ANY (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
}
public function testSomeExpressionWithCorrelatedSubquery()
{
// We need existant classes here, otherwise semantical will always fail
$this->assertValidDql('SELECT * FROM Employee e WHERE e.salary > SOME (SELECT m.salary FROM Manager m WHERE m.department = e.department)');
$this->assertValidDql('SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id > SOME (SELECT u2.id FROM Doctrine\Tests\Models\CMS\CmsUser u2 WHERE u2.name = u.name)');
}
*/
}
\ No newline at end of file
......@@ -26,7 +26,6 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
}
}
public function testPlainFromClauseWithoutAlias()
{
$this->assertSqlGeneration(
......@@ -165,54 +164,75 @@ class SelectSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
);
}
/*public function testFunctionalExpressionsSupportedInWherePart()
// Ticket 894
public function testBetweenDeclarationWithInputParameter()
{
$this->assertSqlGeneration(
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id BETWEEN ?1 AND ?2",
"SELECT c0.name AS c0__name FROM cms_users c0 WHERE c0.id BETWEEN ? AND ?"
);
}
public function testFunctionalExpressionsSupportedInWherePart()
{
$this->assertSqlGeneration(
"SELECT u.name FROM CmsUser u WHERE TRIM(u.name) = 'someone'",
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE TRIM(u.name) = 'someone'",
// String quoting in the SQL usually depends on the database platform.
// This test works with a mock connection which uses ' for string quoting.
"SELECT cu.name AS cu__name FROM CmsUser cu WHERE TRIM(cu.name) = 'someone'"
"SELECT c0.name AS c0__name FROM cms_users c0 WHERE TRIM(FROM c0.name) = 'someone'"
);
}*/
}
/*
// Ticket #973
public function testSingleInValueWithoutSpace()
{
$this->assertSqlGeneration(
"SELECT u.name FROM CmsUser u WHERE u.id IN(46)",
"SELECT cu.name AS cu__name FROM cms_user cu WHERE cu.id IN (46)"
"SELECT u.name FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN(46)",
"SELECT c0.name AS c0__name FROM cms_users c0 WHERE c0.id IN (46)"
);
}
// Ticket 894
public function testBetweenDeclarationWithInputParameter()
public function testInExpressionSupportedInWherePart()
{
$this->assertSqlGeneration(
"SELECT u.name FROM CmsUser u WHERE u.id BETWEEN ? AND ?",
"SELECT cu.name AS cu__name FROM cms_user cu WHERE cu.id BETWEEN ? AND ?"
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id IN (1, 2)',
'SELECT c0.id AS c0__id, c0.status AS c0__status, c0.username AS c0__username, c0.name AS c0__name FROM cms_users c0 WHERE c0.id IN (1, 2)'
);
}
public function testInExpressionSupportedInWherePart()
public function testNotInExpressionSupportedInWherePart()
{
$this->assertSqlGeneration(
'SELECT * FROM CmsUser WHERE CmsUser.id IN (1, 2)',
'SELECT cu.id AS cu__id, cu.status AS cu__status, cu.username AS cu__username, cu.name AS cu__name FROM cms_user cu WHERE cu.id IN (1, 2)'
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id NOT IN (1)',
'SELECT c0.id AS c0__id, c0.status AS c0__status, c0.username AS c0__username, c0.name AS c0__name FROM cms_users c0 WHERE c0.id NOT IN (1)'
);
}
public function testNotInExpressionSupportedInWherePart()
public function testConcatFunction()
{
$connMock = $this->_em->getConnection();
$orgPlatform = $connMock->getDatabasePlatform();
$connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\MySqlPlatform);
$this->assertSqlGeneration(
'SELECT * FROM CmsUser WHERE CmsUser.id NOT IN (1)',
'SELECT cu.id AS cu__id, cu.status AS cu__status, cu.username AS cu__username, cu.name AS cu__name FROM cms_user cu WHERE cu.id NOT IN (1)'
"SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1",
"SELECT c0.id AS c0__id FROM cms_users c0 WHERE CONCAT(c0.name, 's') = ?"
);
$this->assertSqlGeneration(
"SELECT CONCAT(u.id, u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1",
"SELECT CONCAT(c0.id, c0.name) AS dctrn__0 FROM cms_users c0 WHERE c0.id = ?"
);
}
*/
$connMock->setDatabasePlatform(new \Doctrine\DBAL\Platforms\PostgreSqlPlatform);
$this->assertSqlGeneration(
"SELECT u.id FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE CONCAT(u.name, 's') = ?1",
"SELECT c0.id AS c0__id FROM cms_users c0 WHERE c0.name || 's' = ?"
);
$this->assertSqlGeneration(
"SELECT CONCAT(u.id, u.name) FROM Doctrine\Tests\Models\CMS\CmsUser u WHERE u.id = ?1",
"SELECT c0.id || c0.name AS dctrn__0 FROM cms_users c0 WHERE c0.id = ?"
);
$connMock->setDatabasePlatform($orgPlatform);
}
}
\ No newline at end of file
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