views:

92

answers:

2

Apparently alot of ORM's do something like this:

query.filter(username == "bob")

to generate sql like

... WHERE username = 'bob'

Why override the == operator instead of something like:

query.filter(username.eq("bob"))
+3  A: 

This is a subjective question, but in general I would say that the syntax for the former is more intuitive, and since many (if not most) ORM's do this it's generally expected (making it more intuitive).

Adam Robinson
A: 

The whole point of orm is brideing the "impedance mismatch" between object and relational world , So in theory you can be blissfully unaware of "=" in sql world and work with "==" of the object world.

Surya