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

Postgres compatibility #5

Closed
excid3 opened this issue Aug 29, 2021 · 2 comments · Fixed by #6
Closed

Postgres compatibility #5

excid3 opened this issue Aug 29, 2021 · 2 comments · Fixed by #6

Comments

@excid3
Copy link

excid3 commented Aug 29, 2021

Ran into this running on a Postgres app, but wasn't able to pinpoint what needed to change.

ActionView::Template::Error (PG::InvalidColumnReference: ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ...ated_at <= '2021-08-30 23:59:59.999999') ORDER BY "console19...
                                                             ^
):
    1: <article class="message is-info">
    2:   <div class="message-body">
    3:     <%= sessions.count %> sessions (<%= sessions.pending.count %> pending, <%= sessions.approved.count %> approved, <%= sessions.flagged.count %> flagged)
    4:   </div>
    5: </article>

rails (0a4410dace9a) activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:726:in `exec_params'
rails (0a4410dace9a) activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:726:in `block (2 levels) in exec_no_cache'
rails (0a4410dace9a) activesupport/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
rails (0a4410dace9a) activesupport/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
rails (0a4410dace9a) activesupport/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
rails (0a4410dace9a) activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:725:in `block in exec_no_cache'
rails (0a4410dace9a) activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:737:in `block (2 levels) in log'
rails (0a4410dace9a) activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
rails (0a4410dace9a) activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
rails (0a4410dace9a) activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
rails (0a4410dace9a) activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
rails (0a4410dace9a) activesupport/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
rails (0a4410dace9a) activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:736:in `block in log'
rails (0a4410dace9a) activesupport/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
rails (0a4410dace9a) activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:727:in `log'
rails (0a4410dace9a) activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:724:in `exec_no_cache'
rails (0a4410dace9a) activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:703:in `execute_and_clear'
rails (0a4410dace9a) activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:52:in `exec_quer

I think the Auditable distinct calls need to use a group_by instead?

scope :sensitive, -> { joins(:sensitive_accesses).distinct }
@jorgemanrubia
Copy link
Member

Hey @excid3 I'll look into it this week. Thanks for these reports, this certainly should be compatible with postgres!

jorgemanrubia added a commit that referenced this issue Aug 30, 2021
This was making Postgres chockle:

```sql
NOT IN (SELECT "console1984_sessions"."id"
```

#5
jorgemanrubia added a commit that referenced this issue Aug 30, 2021
This was making Postgres choke:

```sql
NOT IN (SELECT "console1984_sessions"."id"
```

#5
@jorgemanrubia
Copy link
Member

jorgemanrubia commented Aug 30, 2021

Released v0.1.1 with a fix for this.

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 a pull request may close this issue.

2 participants