Skip to content

Commit

Permalink
Fix for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Nil Portugues Caldero committed Feb 4, 2016
1 parent e417995 commit 41a192c
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Builder/MySqlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function writeColumnName(Column $column)
return '*';
}

if (false !== strpos($column->getName(), "(")) {
if (false !== strpos($column->getName(), '(')) {
return parent::writeColumnName($column);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Manipulation/ColumnQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function count($columnName = '*', $alias = '')
$count .= ')';

if (isset($alias) && \strlen($alias) > 0) {
$count .= " AS '{$alias}'";
$count .= ' AS "'.$alias.'"';
}

$this->columns = array($count);
Expand Down
8 changes: 4 additions & 4 deletions src/Syntax/Where.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ public function matchWithQueryExpansion(array $columns, array $values)
}

/**
* @param string $column
* @param integer[] $values
* @param string $column
* @param int[] $values
*
* @return $this
*/
Expand All @@ -430,8 +430,8 @@ public function in($column, array $values)
}

/**
* @param string $column
* @param integer[] $values
* @param string $column
* @param int[] $values
*
* @return $this
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/Builder/GenericBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function itShouldOutputHumanReadableQuery()
LIMIT
:v2,
:v3
) AS 'user_role',
) AS "user_role",
(
SELECT
role.role_name
Expand All @@ -222,7 +222,7 @@ public function itShouldOutputHumanReadableQuery()
LIMIT
:v5,
:v6
) AS 'role'
) AS "role"
FROM
user
WHERE
Expand Down
12 changes: 6 additions & 6 deletions tests/Builder/Syntax/ColumnWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function itShouldWriteColumnWithAlias()

$result = $this->columnWriter->writeColumnWithAlias($column);

$this->assertSame('user.user_id AS \'userId\'', $result);
$this->assertSame('user.user_id AS "userId"', $result);
}

/**
Expand All @@ -118,8 +118,8 @@ public function itShouldBeAbleToWriteColumnAsASelectStatement()
->equals('user_id', 4);

$expected = 'SELECT user.user_id, user.username, '.
'(SELECT role.role_name FROM role WHERE (role.role_id = :v1) LIMIT :v2, :v3) AS \'user_role\', '.
'(SELECT role.role_name FROM role WHERE (role.role_id = :v4) LIMIT :v5, :v6) AS \'role\' '.
'(SELECT role.role_name FROM role WHERE (role.role_id = :v1) LIMIT :v2, :v3) AS "user_role", '.
'(SELECT role.role_name FROM role WHERE (role.role_id = :v4) LIMIT :v5, :v6) AS "role" '.
'FROM user WHERE (user.user_id = :v7)';

$this->assertSame($expected, $this->writer->write($this->query));
Expand All @@ -140,7 +140,7 @@ public function itShouldBeAbleToWriteColumnAsAValueStatement()
->where()
->equals('user_id', 1);

$expected = 'SELECT user.user_id, user.username, :v1 AS \'priority\' FROM user WHERE (user.user_id = :v2)';
$expected = 'SELECT user.user_id, user.username, :v1 AS "priority" FROM user WHERE (user.user_id = :v2)';
$this->assertSame($expected, $this->writer->write($this->query));

$expected = array(':v1' => 10, ':v2' => 1);
Expand All @@ -159,7 +159,7 @@ public function itShouldBeAbleToWriteColumnAsAFuncWithBracketsStatement()
->where()
->equals('user_id', 1);

$expected = 'SELECT user.user_id, user.username, MAX(user_id) AS \'max_id\' FROM user WHERE (user.user_id = :v1)';
$expected = 'SELECT user.user_id, user.username, MAX(user_id) AS "max_id" FROM user WHERE (user.user_id = :v1)';
$this->assertSame($expected, $this->writer->write($this->query));

$expected = array(':v1' => 1);
Expand All @@ -178,7 +178,7 @@ public function itShouldBeAbleToWriteColumnAsAFuncWithoutBracketsStatement()
->where()
->equals('user_id', 1);

$expected = 'SELECT user.user_id, user.username, CURRENT_TIMESTAMP AS \'server_time\' FROM user WHERE (user.user_id = :v1)';
$expected = 'SELECT user.user_id, user.username, CURRENT_TIMESTAMP AS "server_time" FROM user WHERE (user.user_id = :v1)';
$this->assertSame($expected, $this->writer->write($this->query));

$expected = array(':v1' => 1);
Expand Down
16 changes: 8 additions & 8 deletions tests/Builder/Syntax/SelectWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function itShouldAllowColumnAlias()
)
);

$expected = "SELECT user.user_id AS 'userId', user.name AS 'username', user.email AS 'email' FROM user";
$expected = 'SELECT user.user_id AS "userId", user.name AS "username", user.email AS "email" FROM user';

$this->assertSame($expected, $this->writer->write($this->query));
}
Expand Down Expand Up @@ -228,7 +228,7 @@ public function itShouldAllowColumnOrderUsingColumnAlias()
->orderBy('email', OrderBy::DESC);

$expected =
'SELECT user.user_id AS \'userId\', user.name AS \'username\', user.email AS \'email\' FROM '.
'SELECT user.user_id AS "userId", user.name AS "username", user.email AS "email" FROM '.
'user ORDER BY user.user_id ASC, user.email DESC';

$this->assertSame($expected, $this->writer->write($this->query));
Expand Down Expand Up @@ -309,7 +309,7 @@ public function itShouldBeAbleToDoALeftJoinWithOrderByOnJoinedTable()
->leftJoin('news', 'user_id', 'author_id', array('title', 'body', 'created_at', 'updated_at'))
->orderBy('created_at', OrderBy::DESC);

$expected = 'SELECT user.user_id AS \'userId\', user.name AS \'username\', user.email AS \'email\', user.created_at,'.
$expected = 'SELECT user.user_id AS "userId", user.name AS "username", user.email AS "email", user.created_at,'.
' news.title, news.body, news.created_at, news.updated_at FROM user LEFT JOIN news ON (news.author_id '.
'= user.user_id) ORDER BY user.user_id DESC, news.created_at DESC';

Expand Down Expand Up @@ -349,7 +349,7 @@ public function itShouldBeAbleToDoAJoinWithOrderByOnJoinedTable()
->join('news', 'user_id', 'author_id', array('title', 'body', 'created_at', 'updated_at'))
->orderBy('created_at', OrderBy::DESC);

$expected = 'SELECT user.user_id AS \'userId\', user.name AS \'username\', user.email AS \'email\', user.created_at,'.
$expected = 'SELECT user.user_id AS "userId", user.name AS "username", user.email AS "email", user.created_at,'.
' news.title, news.body, news.created_at, news.updated_at FROM user JOIN news ON (news.author_id ='.
' user.user_id) ORDER BY user.user_id DESC, news.created_at DESC';

Expand Down Expand Up @@ -405,7 +405,7 @@ public function itShouldBeAbleToOn()

$this->query->limit(1, 10);

$expected = 'SELECT user.user_id AS \'userId\', user.name AS \'username\', user.email AS \'email\', user.created_at,'.
$expected = 'SELECT user.user_id AS "userId", user.name AS "username", user.email AS "email", user.created_at,'.
' news.title, news.body, news.created_at, news.updated_at FROM user JOIN news ON '.
'(news.author_id = user.user_id) AND (news.author_id = :v1) ORDER BY '.
'user.user_id DESC, news.created_at DESC LIMIT :v2, :v3';
Expand Down Expand Up @@ -469,7 +469,7 @@ public function itShouldBeAbleToCountTotalRowsSettingDefaultColumnWithAlias()
->equals('user_id', 1)
->equals('user_id', 2);

$expected = 'SELECT COUNT(user.user_id) AS \'total_users\' FROM user GROUP BY user.user_id, user.name HAVING (user.user_id = :v1) AND (user.user_id = :v2)';
$expected = 'SELECT COUNT(user.user_id) AS "total_users" FROM user GROUP BY user.user_id, user.name HAVING (user.user_id = :v1) AND (user.user_id = :v2)';

$this->assertSame($expected, $this->writer->write($this->query));
$expected = array(':v1' => 1, ':v2' => 2);
Expand All @@ -496,7 +496,7 @@ public function itShouldBeAbleToGroupByOperator()
->equals('user_id', 1)
->equals('user_id', 2);

$expected = 'SELECT user.user_id AS \'userId\', user.name AS \'username\', user.email AS \'email\', user.created_at'.
$expected = 'SELECT user.user_id AS "userId", user.name AS "username", user.email AS "email", user.created_at'.
' FROM user GROUP BY user.user_id, user.name HAVING (user.user_id = :v1) AND (user.user_id = :v2)';

$this->assertSame($expected, $this->writer->write($this->query));
Expand Down Expand Up @@ -545,7 +545,7 @@ public function itShouldBeAbleToSetHavingOperatorToOr()
->equals('user_id', 1)
->equals('user_id', 2);

$expected = 'SELECT user.user_id AS \'userId\', user.name AS \'username\', user.email AS \'email\', user.created_at'.
$expected = 'SELECT user.user_id AS "userId", user.name AS "username", user.email AS "email", user.created_at'.
' FROM user GROUP BY user.user_id, user.name HAVING (user.user_id = :v1) OR (user.user_id = :v2)';

$this->assertSame($expected, $this->writer->write($this->query));
Expand Down
4 changes: 2 additions & 2 deletions tests/Builder/Syntax/WhereWriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,10 @@ public function itShouldAllowWhereConditionAsLiteral()
$this->query
->setTable('user')
->where()
->asLiteral("(username is not null and status=:status)")
->asLiteral('(username is not null and status=:status)')
->notEquals('name', '%N%');

$expected = "SELECT user.* FROM user WHERE (username is not null and status=:status) AND (user.name <> :v1)";
$expected = 'SELECT user.* FROM user WHERE (username is not null and status=:status) AND (user.name <> :v1)';

$this->assertSame($expected, $this->writer->write($this->query));

Expand Down
4 changes: 2 additions & 2 deletions tests/Syntax/WhereTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public function itShouldSetNotExistsCondition()
*/
public function itShouldReturnLiterals()
{
$result = $this->where->asLiteral("(username is not null and status=:status)")->getComparisons();
$this->assertSame("(username is not null and status=:status)", $result[0]);
$result = $this->where->asLiteral('(username is not null and status=:status)')->getComparisons();
$this->assertSame('(username is not null and status=:status)', $result[0]);
}
}

0 comments on commit 41a192c

Please sign in to comment.