Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/Drivers/ConnectionBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,7 @@ public function quoteIdentifier($value)
return $value->value();
}

if ($value === '*') {
return $value;
}

$pieces = explode('.', $value);

foreach ($pieces as $key => $piece) {
$pieces[$key] = '`'.$piece.'`';
}

return implode('.', $pieces);
return $value;
}

/**
Expand Down
26 changes: 13 additions & 13 deletions src/SphinxQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function getConnection()
*
* Examples:
* $query->where('time', '>', SphinxQL::expr('CURRENT_TIMESTAMP'));
* // WHERE `time` > CURRENT_TIMESTAMP
* // WHERE time > CURRENT_TIMESTAMP
*
* @param string $string The string to keep unaltered
*
Expand Down Expand Up @@ -915,20 +915,20 @@ public function match($column, $value = null, $half = false)
*
* Examples:
* $query->where('column', 'value');
* // WHERE `column` = 'value'
* // WHERE column = 'value'
*
* $query->where('column', '=', 'value');
* // WHERE `column` = 'value'
* // WHERE column = 'value'
*
* $query->where('column', '>=', 'value')
* // WHERE `column` >= 'value'
* // WHERE column >= 'value'
*
* $query->where('column', 'IN', array('value1', 'value2', 'value3'));
* // WHERE `column` IN ('value1', 'value2', 'value3')
* // WHERE column IN ('value1', 'value2', 'value3')
*
* $query->where('column', 'BETWEEN', array('value1', 'value2'))
* // WHERE `column` BETWEEN 'value1' AND 'value2'
* // WHERE `example` BETWEEN 10 AND 100
* // WHERE column BETWEEN 'value1' AND 'value2'
* // WHERE example BETWEEN 10 AND 100
*
* @param string $column The column name
* @param string $operator The operator to use
Expand Down Expand Up @@ -989,20 +989,20 @@ public function withinGroupOrderBy($column, $direction = null)
*
* Examples:
* $sq->having('column', 'value');
* // HAVING `column` = 'value'
* // HAVING column = 'value'
*
* $sq->having('column', '=', 'value');
* // HAVING `column` = 'value'
* // HAVING column = 'value'
*
* $sq->having('column', '>=', 'value')
* // HAVING `column` >= 'value'
* // HAVING column >= 'value'
*
* $sq->having('column', 'IN', array('value1', 'value2', 'value3'));
* // HAVING `column` IN ('value1', 'value2', 'value3')
* // HAVING column IN ('value1', 'value2', 'value3')
*
* $sq->having('column', 'BETWEEN', array('value1', 'value2'))
* // HAVING `column` BETWEEN 'value1' AND 'value2'
* // HAVING `example` BETWEEN 10 AND 100
* // HAVING column BETWEEN 'value1' AND 'value2'
* // HAVING example BETWEEN 10 AND 100
*
* @param string $column The column name
* @param string $operator The operator to use
Expand Down
20 changes: 0 additions & 20 deletions tests/SphinxQL/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,26 +202,6 @@ public function testEscapeThrowsException()
$this->connection->escape('\' "" \'\' ');
}

public function testQuoteIdentifier()
{
// test *
$this->assertEquals('*', $this->connection->quoteIdentifier('*'));

// test a normal string
$this->assertEquals('`foo`.`bar`', $this->connection->quoteIdentifier('foo.bar'));

// test a SphinxQLExpression
$this->assertEquals('foo.bar', $this->connection->quoteIdentifier(new Expression('foo.bar')));
}

public function testQuoteIdentifierArr()
{
$this->assertSame(
array('*', '`foo`.`bar`', 'foo.bar'),
$this->connection->quoteIdentifierArr(array('*', 'foo.bar', new Expression('foo.bar')))
);
}

public function testQuote()
{
$this->connection->connect();
Expand Down
22 changes: 11 additions & 11 deletions tests/SphinxQL/FacetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,39 +43,39 @@ public function testFacet()
->facet(array('gid'))
->getFacet();

$this->assertEquals('FACET `gid`', $facet);
$this->assertEquals('FACET gid', $facet);

$facet = Facet::create(self::$conn)
->facet(array('gid', 'title', 'content'))
->getFacet();

$this->assertEquals('FACET `gid`, `title`, `content`', $facet);
$this->assertEquals('FACET gid, title, content', $facet);

$facet = Facet::create(self::$conn)
->facet('gid', 'title', 'content')
->getFacet();

$this->assertEquals('FACET `gid`, `title`, `content`', $facet);
$this->assertEquals('FACET gid, title, content', $facet);

$facet = Facet::create(self::$conn)
->facet(array('aliAS' => 'gid'))
->getFacet();

$this->assertEquals('FACET `gid` AS aliAS', $facet);
$this->assertEquals('FACET gid AS aliAS', $facet);

$facet = Facet::create(self::$conn)
->facet(array('gid', 'name' => 'title', 'content'))
->getFacet();

$this->assertEquals('FACET `gid`, `title` AS name, `content`', $facet);
$this->assertEquals('FACET gid, title AS name, content', $facet);

$facet = new Facet();
$facet = $facet
->setConnection(self::$conn)
->facet('gid', array('name' => 'title'), 'content')
->getFacet();

$this->assertEquals('FACET `gid`, `title` AS name, `content`', $facet);
$this->assertEquals('FACET gid, title AS name, content', $facet);
}

public function testFacetFunction()
Expand All @@ -100,7 +100,7 @@ public function testBy()
->by('gid')
->getFacet();

$this->assertEquals('FACET `gid`, `title`, `content` BY `gid`', $facet);
$this->assertEquals('FACET gid, title, content BY gid', $facet);
}

public function testOrderBy()
Expand All @@ -110,15 +110,15 @@ public function testOrderBy()
->orderBy('gid', 'DESC')
->getFacet();

$this->assertEquals('FACET `gid`, `title` ORDER BY `gid` DESC', $facet);
$this->assertEquals('FACET gid, title ORDER BY gid DESC', $facet);

$facet = Facet::create(self::$conn)
->facet(array('gid', 'content'))
->orderBy('gid', 'ASC')
->orderBy('content', 'DESC')
->getFacet();

$this->assertEquals('FACET `gid`, `content` ORDER BY `gid` ASC, `content` DESC', $facet);
$this->assertEquals('FACET gid, content ORDER BY gid ASC, content DESC', $facet);
}

public function testOrderByFunction()
Expand All @@ -128,7 +128,7 @@ public function testOrderByFunction()
->orderByFunction('COUNT','*', 'DESC')
->getFacet();

$this->assertEquals('FACET `gid`, `title` ORDER BY COUNT(*) DESC', $facet);
$this->assertEquals('FACET gid, title ORDER BY COUNT(*) DESC', $facet);
}

public function testLimit()
Expand All @@ -139,6 +139,6 @@ public function testLimit()
->limit(5, 5)
->getFacet();

$this->assertEquals('FACET `gid`, `title` ORDER BY COUNT(*) DESC LIMIT 5, 5', $facet);
$this->assertEquals('FACET gid, title ORDER BY COUNT(*) DESC LIMIT 5, 5', $facet);
}
}
4 changes: 2 additions & 2 deletions tests/SphinxQL/HelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ public function testMiscellaneous()
$this->assertEquals('SHOW STATUS', $query->compile()->getCompiled());

$query = Helper::create($this->conn)->attachIndex('disk', 'rt');
$this->assertEquals('ATTACH INDEX `disk` TO RTINDEX `rt`', $query->compile()->getCompiled());
$this->assertEquals('ATTACH INDEX disk TO RTINDEX rt', $query->compile()->getCompiled());

$query = Helper::create($this->conn)->flushRtIndex('rt');
$this->assertEquals('FLUSH RTINDEX `rt`', $query->compile()->getCompiled());
$this->assertEquals('FLUSH RTINDEX rt', $query->compile()->getCompiled());
}
}
14 changes: 7 additions & 7 deletions tests/SphinxQL/SphinxQLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,15 +574,15 @@ public function testOption()
->compile()
->getCompiled();

$this->assertEquals('SELECT * FROM `rt` OPTION `comment` = \'this should be quoted\'', $result);
$this->assertEquals('SELECT * FROM rt OPTION comment = \'this should be quoted\'', $result);

$result = SphinxQL::create(self::$conn)->select()
->from('rt')
->option('field_weights', SphinxQL::expr('(content=50)'))
->compile()
->getCompiled();

$this->assertEquals('SELECT * FROM `rt` OPTION `field_weights` = (content=50)', $result);
$this->assertEquals('SELECT * FROM rt OPTION field_weights = (content=50)', $result);

$result = SphinxQL::create(self::$conn)->select()
->from('rt')
Expand All @@ -594,7 +594,7 @@ public function testOption()
->compile()
->getCompiled();

$this->assertEquals('SELECT * FROM `rt` OPTION `field_weights` = (title=80, content=35, tags=92)', $result);
$this->assertEquals('SELECT * FROM rt OPTION field_weights = (title=80, content=35, tags=92)', $result);
}

public function testGroupBy()
Expand Down Expand Up @@ -800,7 +800,7 @@ public function testResetMethods()
->compile()
->getCompiled();

$this->assertEquals('SELECT * FROM `rt`', $result);
$this->assertEquals('SELECT * FROM rt', $result);
}

/**
Expand Down Expand Up @@ -860,7 +860,7 @@ public function testSubselect()
})
->orderBy('id', 'ASC');
$this->assertEquals(
'SELECT * FROM (SELECT `id` FROM `rt` ORDER BY `id` DESC) ORDER BY `id` ASC',
'SELECT * FROM (SELECT id FROM rt ORDER BY id DESC) ORDER BY id ASC',
$query->compile()->getCompiled()
);
$result = $query
Expand All @@ -879,11 +879,11 @@ public function testSubselect()
->from($subquery)
->orderBy('id', 'ASC');
$this->assertEquals(
'SELECT `id` FROM `rt` ORDER BY `id` DESC',
'SELECT id FROM rt ORDER BY id DESC',
$subquery->compile()->getCompiled()
);
$this->assertEquals(
'SELECT * FROM (SELECT `id` FROM `rt` ORDER BY `id` DESC) ORDER BY `id` ASC',
'SELECT * FROM (SELECT id FROM rt ORDER BY id DESC) ORDER BY id ASC',
$query->compile()->getCompiled()
);
$result = $subquery
Expand Down