Skip to content

Commit 306f4f4

Browse files
committed
Fixing testing of aliases
1 parent beb8e5d commit 306f4f4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/SQLParser/Node/NodeFactory.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static function toObject(array $desc)
4242

4343
// If the constant has an alias, it is declared in the columns section.
4444
// If this is the case, let's wrap it in an "expression"
45-
if (isset($desc['alias'])) {
45+
if (isset($desc['alias']['name'])) {
4646
$expression = new Expression();
4747
$expression->setBaseExpression($desc['base_expr']);
4848
$expression->setSubTree($const);
@@ -108,7 +108,7 @@ public static function toObject(array $desc)
108108
$instance->setDatabase($baseName);
109109
}
110110

111-
if (!empty($desc['alias'])) {
111+
if (!empty($desc['alias']['name'])) {
112112
$instance->setAlias($desc['alias']['name']);
113113
}
114114

@@ -225,7 +225,7 @@ public static function toObject(array $desc)
225225
$expr->setJoinType($desc['join_type']);
226226
}
227227

228-
if (isset($desc['alias'])) {
228+
if (isset($desc['alias']['name'])) {
229229
$expr->setAlias($desc['alias']['name']);
230230
}
231231

@@ -285,7 +285,7 @@ public static function toObject(array $desc)
285285
$expr->setSubTree(self::buildFromSubtree($desc['sub_tree']));
286286
}
287287

288-
if (isset($desc['alias'])) {
288+
if (isset($desc['alias']['name'])) {
289289
$expr->setAlias($desc['alias']['name']);
290290
}
291291
if (isset($desc['direction'])) {

tests/Mouf/Database/MagicQueryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function testStandardSelect()
203203
$sql = 'SELECT (id + 2) AS foo FROM bar';
204204
$this->assertEquals($sql, self::simplifySql($magicQuery->build($sql)));
205205

206-
$sql = 'SELECT COUNT(*) FROM (SELECT DISTINCT `states`.`country_id`, `states`.`code` FROM states)';
206+
$sql = 'SELECT COUNT(*) FROM (SELECT DISTINCT states.country_id, states.code FROM states)';
207207
$this->assertEquals($sql, self::simplifySql($magicQuery->build($sql)));
208208
}
209209

0 commit comments

Comments
 (0)