Coder Social home page Coder Social logo

PostgresError about dm-pagination HOT 8 CLOSED

jpgarcia avatar jpgarcia commented on August 19, 2024
PostgresError

from dm-pagination.

Comments (8)

jpgarcia avatar jpgarcia commented on August 19, 2024

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

from dm-pagination.

tj avatar tj commented on August 19, 2024

That is something to take up with DM core, I would not go explicitly deleting :order, because it works fine with other RDMS

from dm-pagination.

jpgarcia avatar jpgarcia commented on August 19, 2024

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!

from dm-pagination.

tj avatar tj commented on August 19, 2024

ah, right sorry didnt look closely enough lol its probably fine then

from dm-pagination.

tj avatar tj commented on August 19, 2024

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

from dm-pagination.

jpgarcia avatar jpgarcia commented on August 19, 2024

good man! now I'm going to remove the monkey patch :)

from dm-pagination.

jpgarcia avatar jpgarcia commented on August 19, 2024

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.

from dm-pagination.

tj avatar tj commented on August 19, 2024

My bad! typo, 1.0.1 fixes this

from dm-pagination.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.