Closed jpgarcia closed 14 years ago
I fixed it by adding a line ( query.delete :order ) in the page method, agree with that?:
def page page = nil, options = {}
options, page = page, nil if page.is_a? Hash
page ||= pager_option :page, options
options.delete :page
page = 1 unless (page = page.to_i) && page > 1
per_page = pager_option(:per_page, options).to_i
query = options.dup
collection = new_collection scoped_query(options = {
:limit => per_page,
:offset => (page - 1) * per_page,
:order => [:id.desc]
}.merge(query))
query.delete :order <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
options.merge! :total => count(query), :page => page
collection.pager = DataMapper::Pager.new options
collection
end
That is something to take up with DM core, I would not go explicitly deleting :order, because it works fine with other RDMS
Ok, anyway removing the option :order will not affect the collection itself, I'm removing the :order only for the aggregate function "count", because the order hasn't any sense for an aggregate function. thanks for your quickly answer!
ah, right sorry didnt look closely enough lol its probably fine then
Cool cool I committed the change :D thanks. Your totally right though I just had read it wrong originally when I scanned over the issue
good man! now I'm going to remove the monkey patch :)
hi visionmedia, it's been a long time since my last message and untill now I didn't deployed the app to heroku and now I'm realizing that the gem still throwing the same exception, this is because you removed the :order option to the 'options' instead of to the 'query' as I wrote in my second message. hope you can modify it for the next version.
My bad! typo, 1.0.1 fixes this
I'm getting this when running on Heroku because of Postgres database:
PostgresError - ERROR: column "medium.sector" must appear in the GROUP BY clause or be used in an aggregate function
Query: SELECT COUNT(*) FROM "medium" ORDER BY "sector" DESC:
BTW: running it locally with sqlite3 is working like a charm, thanks for the gem!