Permalink
Browse files

Adding support for a single ExpressionInterface as the value for

a TupleComparison
  • Loading branch information...
lorenzo committed Jan 12, 2014
1 parent 9b92cc8 commit c2ddf76dd9e3ea741ef6ea96ae8d14bbbeff7164
@@ -66,7 +66,13 @@ public function sql(ValueBinder $generator) {
*/
protected function _stringifyValues($generator) {
$values = [];
- foreach ($this->getValue() as $i => $value) {
+ $parts = $this->getValue();
+
+ if ($parts instanceof ExpressionInterface) {
+ return $parts->sql($generator);
+ }
+
+ foreach ($parts as $i => $value) {
if ($value instanceof ExpressionInterface) {
$values[] = $value->sql($generator);
continue;
@@ -123,4 +123,17 @@ public function testTraverse() {
$this->assertSame($value1, $expressions[2]);
}
+/**
+ * Tests that a single ExpressionInteface can be used as the value for
+ * comparison
+ *
+ * @return void
+ */
+ public function testValueAsSingleExpression() {
+ $value = new QueryExpression('SELECT 1, 1');
+ $f = new TupleComparison(['field1', 'field2'], $value);
+ $binder = new ValueBinder;
+ $this->assertEquals('(field1, field2) = (SELECT 1, 1)', $f->sql($binder));
+ }
+
}

0 comments on commit c2ddf76

Please sign in to comment.