java.jdbc

Consider ["name = ? and age = ?" nil 42]

Details

  • Type: Enhancement Enhancement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Duplicate
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

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.

Activity

Hide
Julian Birch added a comment -

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.

Show
Julian Birch added a comment - 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.
Hide
Sean Corfield added a comment -

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.

Show
Sean Corfield added a comment - 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.
Hide
Sean Corfield added a comment -

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.

Show
Sean Corfield added a comment - 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.
Hide
Sean Corfield added a comment -

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

Show
Sean Corfield added a comment - A subset of what will be implemented as part of JDBC-20

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: