Code Monkey home page Code Monkey logo

Comments (12)

veloper avatar veloper commented on July 20, 2024 1

If you're using the license_finder gem and it's in your Gemfile make sure to set :require => false option or else Sequel will be introduced into your Rails project alongside ActiveRecord.

from arel.

jeremyevans avatar jeremyevans commented on July 20, 2024

I'm not sure this is an Arel bug, since the buggy code is in ActiveRecord. The issue was introduced in rails/rails@a1c05dd. Looking at that commit, there's definitely a reason for the change, so you aren't going to want to just revert it. Hopefully the respond_to?(:as) check can be switched to something better. @ernie, do you have any ideas?

from arel.

ernie avatar ernie commented on July 20, 2024

Yeah, there's definitely a reason for the change. @jeremyevans, is it safe for me to assume that since Sequel users who are also using AR are being bitten by this bug, that Sequel monkeypatches String with an implementation of #as?

I'm really loathe to go back to checking for included modules or such, though if we really, really needed to, some refactoring at the ARel level would let us check for inclusion of Arel::AliasPredication. Did I mention I'm not really OK with doing that, though?

from arel.

ernie avatar ernie commented on July 20, 2024

Answering my own question: yeah -- https://github.com/jeremyevans/sequel/blob/master/lib/sequel/extensions/core_extensions.rb#L173

Looks like that's the culprit. :(

from arel.

jeremyevans avatar jeremyevans commented on July 20, 2024

Correct. Sequel can be used without any core extensions by requiring sequel/no_core_ext (a feature I don't believe ActiveRecord offers), but that's not going to be the default till Sequel 4.

FWIW, Sequel has defined String#as and Symbol#as for over 4 years, and this is the first case I'm aware of of something breaking because of it.

from arel.

ernie avatar ernie commented on July 20, 2024

Is it common to use both Sequel and AR in the same project? I always sort of imagined Sequel was more of an alternative to AR vs something you'd only use piecemeal.

from arel.

ernie avatar ernie commented on July 20, 2024

One thing to note, as a workaround, is that it's possible to teach ARel how to visit the Sequel::SQL::AliasedExpression, since it looks like your implementation of #as otherwise conforms to the same API as ARel's.

from arel.

ernie avatar ernie commented on July 20, 2024

If discussion is to continue on this, it probably makes sense to move it to the Rails issue tracker, with a reference to this issue. It's not an issue with ARel, really.

from arel.

joevandyk avatar joevandyk commented on July 20, 2024

@ernie a quick search of rails issues didn't turn up any tickets related to this .. you know if there's any fix?

from arel.

ernie avatar ernie commented on July 20, 2024

@joevandyk I wouldn't say this would be optimal but the only fix that comes to mind, if you must have Sequel's monkeypatches on String, it would be possible to check the as method's owner.

from arel.

joevandyk avatar joevandyk commented on July 20, 2024

BTW, for people who are coming across this bug, instead of

require 'sequel'
use
require 'sequel/no_core_ext'

And make sure that you don't have require 'sequel' anywhere.

This will remove sequel's monkeypatches on a couple core objects -- and you probably don't need those anyways. This will be the default behavior for sequel 4.0.

from arel.

subdigital avatar subdigital commented on July 20, 2024

+1, thanks @veloper -- that was the cause for me as well.

from arel.

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.