GithubHelp home page GithubHelp logo

Comments (3)

ddnexus avatar ddnexus commented on June 15, 2024 2

Thank you! Fixed in 7.0.2.

from pagy.

ddnexus avatar ddnexus commented on June 15, 2024

Hi @elliotlarson, I would need a working self contained support to reproduce this with one click and start working on the fix.
I am afraid a verbal description of your code, is not enough, sorry.

Thanks.

from pagy.

elliotlarson avatar elliotlarson commented on June 15, 2024

Okay, how about this script pagy_error.rb:

require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "sqlite3"
  gem "activerecord"
  gem "pagy"
  gem "debug"
end

require "active_record"

include Pagy::Backend

ActiveRecord::Base.logger = Logger.new(STDOUT)

ActiveRecord::Base.establish_connection(
  adapter: "sqlite3",
  database: ":memory:", # using in memory data store
)

ActiveRecord::Schema.define do
  create_table :manufacturers do |t|
    t.string :name
  end

  create_table :panels do |t|
    t.string :name
    t.integer :manufacturer_id
  end

  create_table :projects do |t|
    t.string :name
    t.integer :panel_id
  end
end

class Manufacturer < ActiveRecord::Base
  has_many :panels

  scope(
    :with_counts, lambda do
      table = arel_table
      panels = Panel.arel_table
      active_panels_count = panels
        .project(Arel.star.count)
        .where(table[:id].eq(panels[:manufacturer_id]))
        .as("active_panels_count")
      select(
        table[Arel.star],
        active_panels_count,
      )
    end
  )
end

class Project < ActiveRecord::Base
  belongs_to :panel
  belongs_to :manufacturer
end

class Panel < ActiveRecord::Base
  belongs_to :manufacturer
end

manufacturers = Manufacturer.with_counts
debugger

pagy, manufacturers = pagy(Manufacturer.with_counts)
debugger

You get to the first debugger successfully, but if you continue, SQLite throws an error when the pagy method is called.

Note: I'm running this with Ruby 3.2.3

from pagy.

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.