<< Back to previous view

[JDBC-18] Consider ["name = ? and age = ?" nil 42] Created: 11/Oct/11  Updated: 01/Jun/16  Resolved: 12/Aug/12

Status: Closed
Project: java.jdbc
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Sean Corfield Assignee: Sean Corfield
Resolution: Duplicate Votes: 0
Labels: None


The query is "name = nil and age = 42" where the intent is probably "name is null and age = 42".

It's not clear whether this is really the library's responsibility (to rewrite the SQL) or whether this should be handled by another layer above so this ticket is a placeholder for discussion.

Comment by Julian Birch [ 13/Oct/11 1:43 PM ]

I've been thinking about this a bit more, and I'm thinking that a function "match-clause" might deal with this in a fairly composable way. So

(match-clause { :name nil :age 42 })

would return

["Name is null and Age = ?" 42]

It's not exactly ClojureQL, but it's non-invasive and makes query-by-example easy to achieve.

Comment by Sean Corfield [ 13/Oct/11 2:28 PM ]

That's nice idea. I actually do something similar in the CRUD wrapper I built around java.jdbc at World Singles so that might be a nice addition to the library.

Comment by Sean Corfield [ 12/Aug/12 9:39 PM ]

This will be incorporated into the new API I'm adding in JDBC-20 so you can say (where {:name nil :age 42}) and it will return the correct SQL where clause. Accordingly, I'm closing this as a duplicate.

Comment by Sean Corfield [ 12/Aug/12 9:39 PM ]

A subset of what will be implemented as part of JDBC-20

Generated at Wed Jan 17 12:43:10 CST 2018 using JIRA 4.4#649-r158309.