summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2017-06-01 15:01:06 +0200
committerMichal Čihař <michal@cihar.com>2017-06-01 15:01:06 +0200
commit4af06d24b041e499fb0e75ab3a98caf9a91700ef (patch)
tree452f3b5da98de5108a90757a699993488566b1e0
parentf18666a810fd84bf5a00145e6b39453a1987e835 (diff)
downloadsql-parser-4af06d24b041e499fb0e75ab3a98caf9a91700ef.zip
sql-parser-4af06d24b041e499fb0e75ab3a98caf9a91700ef.tar.gz
sql-parser-4af06d24b041e499fb0e75ab3a98caf9a91700ef.tar.bz2
Remove not used type arg from GROUP BY
It should not be there since beginning. Issue #154 Signed-off-by: Michal Čihař <michal@cihar.com>
-rw-r--r--src/Components/GroupKeyword.php15
-rw-r--r--tests/Builder/SelectStatementTest.php2
-rw-r--r--tests/Components/GroupKeywordTest.php6
3 files changed, 7 insertions, 16 deletions
diff --git a/src/Components/GroupKeyword.php b/src/Components/GroupKeyword.php
index 4fb667f..1c7dfdd 100644
--- a/src/Components/GroupKeyword.php
+++ b/src/Components/GroupKeyword.php
@@ -21,29 +21,20 @@ use PhpMyAdmin\SqlParser\TokensList;
class GroupKeyword extends Component
{
/**
- * The expression that is used for ordering.
+ * The expression that is used for grouping.
*
* @var Expression
*/
public $expr;
-
- /**
- * The order type.
- *
- * @var string
- */
- public $type;
/**
* Constructor.
*
* @param Expression $expr the expression that we are sorting by
- * @param string $type the sorting type
*/
- public function __construct($expr = null, $type = '')
+ public function __construct($expr = null)
{
$this->expr = $expr;
- $this->type = $type;
}
/**
@@ -135,7 +126,7 @@ class GroupKeyword extends Component
return implode(', ', $component);
}
- return trim($component->expr . ' ' . $component->type);
+ return trim($component->expr);
}
}
diff --git a/tests/Builder/SelectStatementTest.php b/tests/Builder/SelectStatementTest.php
index a1d9e55..f9db69e 100644
--- a/tests/Builder/SelectStatementTest.php
+++ b/tests/Builder/SelectStatementTest.php
@@ -46,7 +46,7 @@ class SelectStatementTest extends TestCase
$this->assertEquals(
'SELECT sgu.id, sgu.email_address FROM `sf_guard_user` AS `sgu` '
. 'RIGHT JOIN `student_course_booking` AS `scb` ON sgu.id = scb.user_id '
- . 'WHERE `has_found_course` = \'1\' GROUP BY sgu.id ASC '
+ . 'WHERE `has_found_course` = \'1\' GROUP BY sgu.id '
. 'ORDER BY scb.id DESC LIMIT 0, 300 ',
$stmt->build()
);
diff --git a/tests/Components/GroupKeywordTest.php b/tests/Components/GroupKeywordTest.php
index 515de6b..8d4a407 100644
--- a/tests/Components/GroupKeywordTest.php
+++ b/tests/Components/GroupKeywordTest.php
@@ -13,12 +13,12 @@ class GroupKeywordTest extends TestCase
$this->assertEquals(
GroupKeyword::build(
array(
- new GroupKeyword(new Expression('a'), 'ASC'),
- new GroupKeyword(new Expression('b'), 'DESC'),
+ new GroupKeyword(new Expression('a')),
+ new GroupKeyword(new Expression('b')),
new GroupKeyword(new Expression('c')),
)
),
- 'a ASC, b DESC, c'
+ 'a, b, c'
);
}
}