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

Keyword "Or" not working properly [DATACOUCH-251] #565

Closed
spring-projects-issues opened this issue Sep 21, 2016 · 1 comment
Closed

Keyword "Or" not working properly [DATACOUCH-251] #565

spring-projects-issues opened this issue Sep 21, 2016 · 1 comment
Labels
type: bug
Milestone

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Sep 21, 2016

Joe Pritzel opened DATACOUCH-251 and commented

Given:

@Repository
public  interface MotorcycleRepository extends CrudRepository<Motorcycle, String> {
  Iterable<Motorcycle> findByMakeOrModel(String make, String model);
}

@Repository
public  interface BoatRepository extends CrudRepository<Boat, String> {
  // These don't even matter, just showing the Boat object has make and model fields
  Iterable<Boat> findByMake(String make);
  Iterable<Boat> findByModel(String model);
}

Data:
{"_class": "com.example.Boat", "make":"Yamaha", "model":"SX190" }
{"_class": "com.example.Boat", "make":"Yamaha", "model":"AR190" }
{"_class": "com.example.Motorcycle", "make":"Yamaha", "model":"YZF-R1" }
{"_class": "com.example.Motorcycle", "make":"Yamaha", "model":"YZF-R1S" }

When:
Calling motorcycleRepository.findByMakeOrModel("Yamaha", "YZF-R1")

Then:
We get back the following:
{"_class": "com.example.Boat", "make":"Yamaha", "model":"SX190" }
{"_class": "com.example.Boat", "make":"Yamaha", "model":"AR190" }
{"_class": "com.example.Motorcycle", "make":"Yamaha", "model":"YZF-R1" }
{"_class": "com.example.Motorcycle", "make":"Yamaha", "model":"YZF-R1S" }

Instead of:
{"_class": "com.example.Motorcycle", "make":"Yamaha", "model":"YZF-R1" }
{"_class": "com.example.Motorcycle", "make":"Yamaha", "model":"YZF-R1S" }

The where clause that is being generates is:

WHERE `make` = "Yamaha" OR "model" = "YZF-R1" AND `_class` = "com.example.Motorcycle"

It should be:

WHERE (`make` = "Yamaha" OR "model" = "YZF-R1") AND `_class` = "com.example.Motorcycle"

Referenced from: pull request #123

Backported to: 2.2 RC1 (Ingalls), 2.1.6 (Hopper SR6)

1 votes, 3 watchers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug
Projects
None yet
Development

No branches or pull requests

1 participant