Code Monkey home page Code Monkey logo

Comments (2)

casperisfine avatar casperisfine commented on May 27, 2024

Interesting.

So this limitation isn't very surprising when you know that Arel compilation uses the common visitor pattern, so Arel will commonly use K * tree_depth stack frames to compile an AST, and Ruby the Ruby stack is finite, hence Arel has an implicit max depth limit.

Interestingly, in your stacktraces, it's the hash method that raises, but it's because it similarly recursively digest child nodes, so same problem. #41597 is what started calling hash, but I suspect compiling to SQL would similarly run out of stack space (if not the limit probably isn't that much further).

One way we may be able to improve this is by changing the Or node, so it's no longer a binary node, but can contain any number of conditions.

That would fix your specific problem, and generally probably reduce the depth of trees a bit, but the same problem may exist with other types of nodes. And I'm also not sure yet whether this solution is even doable, I'd need to try to see.

And also, even if it works, it would be a big enough change that I don't think it would be realistic to backport it as a bug fix to be honest.

from rails.

markedmondson avatar markedmondson commented on May 27, 2024

Thank you @casperisfine - I'll try patching this locally and see if it solves our specific use-case!

from rails.

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.