Skip to content

Instantly share code, notes, and snippets.

@wilig
Created August 8, 2010 02:33
Show Gist options
  • Save wilig/513486 to your computer and use it in GitHub Desktop.
Save wilig/513486 to your computer and use it in GitHub Desktop.
sequel> (filter (> :projects/id 5) (collect :projects))
"select * from projects where projects.id > 5"
sequel> (filter (and (> :projects/id 2) (= :projects/name "sequel")) (collect :projects))
"select * from projects where projects.id > 2 AND projects.name = 'sequel'"
sequel> (filter (and (in :projects/id [1 2 3 4 5 6 7 8 9 10]) (= :projects/name "sequel")) (collect :projects))
"select * from projects where projects.id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND projects.name = 'sequel'"
sequel> (filter (and (in :projects/id [1 2 3 4 5 6 7 8 9 10]) (like :projects/name "seq%")) (collect :projects))
"select * from projects where projects.id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) AND projects.name like 'seq%'"
sequel> (filter (or (and (> :project/id 5) (= :project/name "sequel")) (= :project/id 15)) (collect :projects))
"select * from projects where project.id > 5 AND project.name = 'sequel' OR project.id = 15"
sequel> ;; Oops, nesting doesn't work!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment