Skip to content

Commit

Permalink
Merge pull request #4835 from cakephp/issue-4830
Browse files Browse the repository at this point in the history
Remove AS from table aliases.
  • Loading branch information
markstory committed Oct 11, 2014
2 parents 060a41c + 87d6537 commit 797ce52
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Database/QueryCompiler.php
Expand Up @@ -175,7 +175,7 @@ protected function _buildFromPart($parts, $query, $generator) {
$parts = $this->_stringifyExpressions($parts, $generator);
foreach ($parts as $k => $p) {
if (!is_numeric($k)) {
$p = $p . ' AS ' . $k;
$p = $p . ' ' . $k;
}
$normalized[] = $p;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Database/Driver/SqlserverTest.php
Expand Up @@ -182,7 +182,7 @@ public function testSelectLimitOldServer() {
->from('articles')
->offset(10);
$expected = 'SELECT * FROM (SELECT id, title, (ROW_NUMBER() OVER (ORDER BY (SELECT NULL))) AS [_cake_page_rownum_] ' .
'FROM articles) AS _cake_paging_ ' .
'FROM articles) _cake_paging_ ' .
'WHERE _cake_paging_._cake_page_rownum_ > :c0';
$this->assertEquals($expected, $query->sql());

Expand All @@ -192,7 +192,7 @@ public function testSelectLimitOldServer() {
->order(['id'])
->offset(10);
$expected = 'SELECT * FROM (SELECT id, title, (ROW_NUMBER() OVER (ORDER BY id)) AS [_cake_page_rownum_] ' .
'FROM articles) AS _cake_paging_ ' .
'FROM articles) _cake_paging_ ' .
'WHERE _cake_paging_._cake_page_rownum_ > :c0';
$this->assertEquals($expected, $query->sql());

Expand All @@ -204,7 +204,7 @@ public function testSelectLimitOldServer() {
->limit(10)
->offset(50);
$expected = 'SELECT * FROM (SELECT id, title, (ROW_NUMBER() OVER (ORDER BY id)) AS [_cake_page_rownum_] ' .
'FROM articles WHERE title = :c0) AS _cake_paging_ ' .
'FROM articles WHERE title = :c0) _cake_paging_ ' .
'WHERE (_cake_paging_._cake_page_rownum_ > :c1 AND _cake_paging_._cake_page_rownum_ <= :c2)';
$this->assertEquals($expected, $query->sql());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Database/QueryTest.php
Expand Up @@ -2560,11 +2560,11 @@ public function testQuotingFromAndAlias() {

$query = new Query($this->connection);
$sql = $query->select('*')->from(['foo' => 'something'])->sql();
$this->assertQuotedQuery('FROM <something> AS <foo>$', $sql);
$this->assertQuotedQuery('FROM <something> <foo>$', $sql);

$query = new Query($this->connection);
$sql = $query->select('*')->from(['foo' => $query->newExpr('bar')])->sql();
$this->assertQuotedQuery('FROM \(bar\) AS <foo>$', $sql);
$this->assertQuotedQuery('FROM \(bar\) <foo>$', $sql);
}

/**
Expand Down

0 comments on commit 797ce52

Please sign in to comment.