Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg does not allow aliases in the having clause, but functions are fine #2829

Merged
merged 1 commit into from
Sep 3, 2011

Conversation

arunagw
Copy link
Member

@arunagw arunagw commented Sep 3, 2011

Fixed tests.

master commit 5a05207

test_should_group_by_summed_field_having_condition_from_select(CalculationsTest):
ActiveRecord::StatementInvalid: PGError: ERROR:  column "min_credit_limit" does not exist
LINE 1: ... firm_id FROM "accounts"  GROUP BY firm_id HAVING min_credit...
                                                             ^
: SELECT SUM("accounts"."credit_limit") AS sum_credit_limit, MIN(credit_limit) AS min_credit_limit, firm_id AS firm_id FROM "accounts"  GROUP BY firm_id HAVING min_credit_limit > 50
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:962:in `async_exec'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:962:in `exec_no_cache'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:551:in `block in exec_query'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `block in log'
    /Users/arunagw/checkouts/rails/activesupport/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:550:in `exec_query'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:1031:in `select'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:18:in `select_all'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:63:in `select_all'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/relation/calculations.rb:258:in `execute_grouped_calculation'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/relation/calculations.rb:185:in `perform_calculation'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/relation/calculations.rb:155:in `calculate'
    /Users/arunagw/checkouts/rails/activerecord/lib/active_record/relation/calculations.rb:93:in `sum'
    /Users/arunagw/checkouts/rails/activerecord/test/cases/calculations_test.rb:174:in `test_should_group_by_summed_field_having_condition_from_select'
    /Users/arunagw/checkouts/rails/bundle/ruby/1.9.1/gems/mocha-0.9.12/lib/mocha/integration/mini_test/version_142_to_172.rb:27:in `run'
    /Users/arunagw/checkouts/rails/activesupport/lib/active_support/testing/setup_and_teardown.rb:35:in `block in run'
    /Users/arunagw/checkouts/rails/activesupport/lib/active_support/callbacks.rb:408:in `_run_setup_callbacks'

tenderlove added a commit that referenced this pull request Sep 3, 2011
pg does not allow aliases in the having clause, but functions are fine
@tenderlove tenderlove merged commit 66754c4 into rails:3-1-stable Sep 3, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants