Skip to content

Deep conditions nesting on sqlite => stack overflow  #805

@NikolaiKircher

Description

@NikolaiKircher

I am resubmitting this issue from the archived cancan project: Deep conditions nesting on sqlite => stack overflow

Steps to reproduce

https://gist.github.com/NikolaiKircher/5f31bf2b0f9bf969597ce5e6e3f6551f

=> ActiveRecord::StatementInvalid: SQLite3::SQLException: parser stack overflow

Actual behaviour

CanCan constructs sql like so

... where cond0 OR (
  cond1 OR (
    cond2 ...
  )
)

this useless deep nesting on sqlite3 results in a Parser Stack Overflow error.

Expected behaviour

A better SQL would be:

... where cond0 OR cond1 OR cond2 ...

System configuration

Rails version:
6.1.7
Ruby version:
3.0.4
CanCanCan version
3.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions