Skip to content

Loading…

ExpressionBuilder in and notIn methods #192

Merged
merged 3 commits into from

4 participants

@Xobb

ExpressionBuilder is missing in and not in methods to produce these statements.

@travisbot

This pull request fails (merged aa4f09c into bb88ba7).

@travisbot

This pull request fails (merged aa4f09c into bb88ba7).

@stof
Doctrine member

Please run your own tests when adding them :)

@Xobb

My bad, didn't have the environment set up completely on the new workstation.

@travisbot

This pull request passes (merged 802109c into bb88ba7).

@stof
Doctrine member

Please revert the permission changes. These files have no reason to be executable.

If you are on windows, you should configure git to ignore the file mode as windows does not have filemode properly and so messes it

@Xobb

@stof, thanks, didn't know how to fix that issue with file modes. And you're right, I'm currently on windows with cygwin so it drives me nuts.

@travisbot

This pull request passes (merged f812cc8 into bb88ba7).

@beberlei beberlei merged commit 3965d4f into doctrine:master

1 check passed

Details default The Travis build passed
@Xobb

@beberlei this might be also backported to previous doctrine dbal versions.

@stof
Doctrine member

@Xobb new features are not backported. This is the difference between minor releases and maintenance releases which only receive bugfixes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 27, 2012
  1. @Xobb
Commits on Aug 28, 2012
  1. @Xobb

    Fixed the test.

    Xobb committed
  2. @Xobb

    Changed the file mode back.

    Xobb committed
View
26 lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php
@@ -250,6 +250,32 @@ public function like($x, $y)
}
/**
+ * Creates a IN () comparison expression with the given arguments.
+ *
+ * @param string $x field in string format to be inspected by IN() comparison.
+ * @param array $y Array of values to be used by IN() comparison.
+ *
+ * @return string
+ */
+ public function in($x, array $y)
+ {
+ return $this->comparison($x, 'IN', '('.implode(', ', $y).')');
+ }
+
+ /**
+ * Creates a NOT IN () comparison expression with the given arguments.
+ *
+ * @param string $x field in string format to be inspected by NOT IN() comparison.
+ * @param array $y Array of values to be used by NOT IN() comparison.
+ *
+ * @return string
+ */
+ public function notIn($x, array $y)
+ {
+ return $this->comparison($x, 'NOT IN', '('.implode(', ', $y).')');
+ }
+
+ /**
* Quotes a given input parameter.
*
* @param mixed $input Parameter to be quoted.
View
10 tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php
@@ -198,4 +198,14 @@ public function testIsNotNull()
{
$this->assertEquals('u.updated IS NOT NULL', $this->expr->isNotNull('u.updated'));
}
+
+ public function testIn()
+ {
+ $this->assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', array(1,3,4,7)));
+ }
+
+ public function testNotIn()
+ {
+ $this->assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', array(1,3,4,7)));
+ }
}
Something went wrong with that request. Please try again.