fukamachi / mito

An ORM for Common Lisp with migrations, relationships and PostgreSQL support
292 stars 31 forks source link

Function select-by-sql was exported and now accepts :binds parameter like retrieve-by-sql #55

Closed svetlyak40wt closed 5 years ago

svetlyak40wt commented 5 years ago

This makes possible to write SQL by hand in cases where you need something complex like that:

(mito.dao:select-by-sql
 'top-item
 "SELECT * FROM (
      SELECT score.*,
             row_number() OVER (ORDER BY total DESC) AS position
        FROM score
  ) AS t
   WHERE position > ?
   ORDER BY position
   LIMIT ?"
 :binds (list (- user-position
                 (floor (/ limit 2)))
              limit))
svetlyak40wt commented 5 years ago

Probably, this example should be added to the README.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.03%) to 71.751% when pulling ae2da11980d9718307869808a901ac6158fc0856 on svetlyak40wt:select-by-sql-with-binds into be0ea57df921aa1beb2045b50a8c2e2e4f8b8955 on fukamachi:master.

svetlyak40wt commented 5 years ago

@fukamachi Eitaro, what do you think about this improvement?

fukamachi commented 5 years ago

Great! Thanks :)