Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for comparing multivalue numeric fields #243

Merged
merged 1 commit into from
Feb 13, 2015

Conversation

dantleech
Copy link
Contributor

This is just a POC for now.

if ($this->platform instanceof MySqlPlatform) {
switch ($operator) {
case '=':
case '!=':
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ignore this switch case..

@lsmith77 lsmith77 changed the title Support for comparing multivalue numeric fields [POC] Support for comparing multivalue numeric fields Feb 4, 2015
@dantleech
Copy link
Contributor Author

@dbu @lsmith77 what do you think to this approach?

@lsmith77
Copy link
Member

lsmith77 commented Feb 9, 2015

if it fixes the issue, then its fine to me. however I wonder if we have the issue with SQLite/PostgreSQL as well? I guess a test case makes sense ..

@dantleech
Copy link
Contributor Author

I imagine we will, lets add a test case and see how it goes.

@dbu
Copy link
Member

dbu commented Feb 9, 2015

seems to only work for postgres. and we seem to have some issue with reloading fixtures.

@dantleech
Copy link
Contributor Author

Thats odd, I am pretty sure I developed it in MySQL. Will have another look soon regardless.

@dbu dbu added this to the 1.2 milestone Feb 9, 2015
@dbu
Copy link
Member

dbu commented Feb 9, 2015

i added this to the 1.2 milestone, as lukas says this is important for sulu. is it?

@dantleech
Copy link
Contributor Author

yeah, it would be very useful /cc @wachterjohannes

@dantleech dantleech force-pushed the compare_multivalue_integer branch from 6444738 to 520d698 Compare February 12, 2015 08:24
@dantleech
Copy link
Contributor Author

ok this should pass now, although I suspect we still have a flaky test lurking in master. (/container/idExample not found).

This PR also makes me think that we should handle the query building with events, or at least provide a more structured way of specializing queries for different drivers. Maybe something to think about.

@dbu
Copy link
Member

dbu commented Feb 12, 2015

the flaky test is noted in #239

@dbu
Copy link
Member

dbu commented Feb 12, 2015

mysql reliably fails. is this related to what you are doing or not?

@dantleech
Copy link
Contributor Author

yeah sorry -- just found out I was only testing locally on sqlite. debugging MySQL now.

@dantleech
Copy link
Contributor Author

ok, builds now passing apart from the flaky sqlite.

$operator . " " .
$literalOperand->getLiteralValue();

if ($this->platform instanceof MySqlPlatform) {
Copy link
Member

Choose a reason for hiding this comment

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

to make this more readable, could we do?

if ($this->platform instanceof MySqlPlatform && in_array($operator, array('=', '!='))) {
    return sprintf(...
}

@dbu
Copy link
Member

dbu commented Feb 12, 2015

great. apart from the readability i think this is good now. i really would merge the if and the switch into one, about the assignment vs direct return i'd prefer the direct return but don't mind too much.

can you then squash the commits please?

@dantleech dantleech force-pushed the compare_multivalue_integer branch from eeaf124 to 91072a2 Compare February 12, 2015 12:36
@dantleech
Copy link
Contributor Author

Restructured the code. Also found out that != is not valid JCR-SQL2. So have just made it act only on equality for now.

@dantleech dantleech force-pushed the compare_multivalue_integer branch from 91072a2 to 2f2a7a0 Compare February 12, 2015 12:41
@dantleech
Copy link
Contributor Author

and squashed.

$operator . " " .
$literalOperand->getLiteralValue();

if ($this->platform instanceof MySqlPlatform && $operator == '=') {
Copy link
Member

Choose a reason for hiding this comment

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

if ($this->platform instanceof MySqlPlatform && $operator == '=') {

=>

if ($this->platform instanceof MySqlPlatform && '=' === $operator) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does === offer any advantage here? Changed anyway.

Copy link
Member

Choose a reason for hiding this comment

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

its slightly faster and of course its type safe. I just find it a good practice to "default" to ===

@dantleech dantleech force-pushed the compare_multivalue_integer branch from 2f2a7a0 to 594b8cd Compare February 12, 2015 12:47
@dantleech
Copy link
Contributor Author

good to merge?

dbu added a commit that referenced this pull request Feb 13, 2015
[POC] Support for comparing multivalue numeric fields
@dbu dbu merged commit fd08086 into master Feb 13, 2015
@dbu dbu deleted the compare_multivalue_integer branch February 13, 2015 14:10
@dbu
Copy link
Member

dbu commented Feb 13, 2015

great, thanks a lot!

@dbu dbu changed the title [POC] Support for comparing multivalue numeric fields Support for comparing multivalue numeric fields Feb 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants