Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Db/Sql/Predicate/Expression: Fix method argument handling #6849

Closed

Conversation

Pittiplatsch
Copy link

  • Fix method argument handling of Predicate/Expression to allow single non-scalar values (e.g. null, Predicate instances) as only parameter
  • Fix typo in Predicate/Predicate

Lars Heber added 3 commits November 6, 2014 12:18
non-scalar values (e.g. null, Predicate instances) as only parameter
* Fix typo in Predicate/Predicate
@@ -57,10 +139,4 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfLiteralAndPar
$test = $expression->getExpressionData();
$this->assertEquals($expected, $test, var_export($test, 1));
}

public function testAllowZeroParameterValue()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this test was changed/removed: should I assume there is a BC break?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test is replaced with testCanPassSingleZeroParameterValueToConstructor().
The 0 part is the important, tested one, where 'foo.bar > ?' is actually irrelevant for this test.
Thus: no BC

@Ocramius Ocramius self-assigned this Nov 22, 2014
@Ocramius Ocramius added this to the 2.3.4 milestone Dec 16, 2014
Ocramius added a commit that referenced this pull request Dec 16, 2014
Ocramius added a commit that referenced this pull request Dec 16, 2014
@Ocramius Ocramius closed this in 94c63f7 Dec 16, 2014
@Ocramius
Copy link
Member

@Pittiplatsch merged and applied minor tweaks, thanks!

master: 94c63f7
develop: f7abc3b

@Pittiplatsch Pittiplatsch deleted the db_expression_parameters branch January 15, 2015 12:31
@darpla
Copy link

darpla commented Nov 6, 2017

The changes introduced a BC break! The $valueParameter argument in the constructor has the default value null, which in the old code meant that the provided expression has no parameters. Now the new code treats this null as a query parameter and therefore the old queries fail due to this!
This means that such constructs now will fail with error 'The number of replacements in the expression does not match the number of parameters' during query preparation, because the class thinks that there is an unused parameter:

$select = $this->tableGateway->getSql()->select();
$select->where->expression('DATE(close_date - INTERVAL reminder_days DAY) = DATE(NOW())');

P.S. The Sql\Expression class handles this case still the old way - as it should, without BC break.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants