I'm using the latest versions of postgresql, ruby and datamapper.
I create a query like so:
collection = Entry.all(:id => 2..4, :text => /test/)
collection
is a DataMapper::Collection
object. It's possible to get the DataMapper::Query
object by simply calling query = collection.query
. But how do I get the raw SQL of my query, as a String?
I need it because I have to customize the raw SQL (I need SELECT DISTINCT
instead of only SELECT
), but I don't want to write the SQL completely by myself, because I'm not sure if I can write a secure query.
I would also be happy to archive my goal another way, I'm open to completely new suggestions ;)