Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • T torque-postgresql
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 6
    • Issues 6
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Carlos
  • torque-postgresql
  • Issues
  • #23
Closed
Open
Issue created Nov 21, 2018 by Carlos@crashtechOwner

Auxiliary Statements doesn't work with Inheritance

Consider

# /app/models/account.rb
class Account < Account
  auxiliary_statement :balance do |cte|
    cte.query AccountTransaction.approved.group(:account_id)
    cte.attributes col(:value).sum => :balance
    cte.join_type :left
  end
end

# /app/models/user.rb
class User < Account
end

The following doesn't work:

User.with(:balance).first.balance
# There's no 'balance' auxiliary statement defined

The current workaround is the following

Account.cast_records(User, filter: true).with(:balance).first.balance
Assignee
Assign to
Time tracking