Giter Site home page Giter Site logo

Comments (2)

searls avatar searls commented on June 20, 2024

Some thoughts: AR's default == behavior makes for a really bad out-of-the-box experience with Suture

I am truly happy to release a Suture 1.0.0 without any AR-specific affordances, but for the fact that by default users will get confusing false positives if they pass in or return AR objects to and from seams.

By default, AR will consider two already-persisted objects equivalent if their IDs match. This is definitely a problem with Suture'a default comparator, because drastically-mutated AR objects will be seen as "passing" in Suture.verify tests and as comparable in staging (e.g. call_both mode).

Since some woefully high percentage of legacy Ruby classes extend from AR::Base, this is a terrible out-of-the-box experience because it looks like it's passing immediately, the user must recognize it is not, and then figure out the Custom Comparator API to look at just the properties they care about.

This is unacceptably bad UX IMO.

from suture.

searls avatar searls commented on June 20, 2024

My inclination at this point is to do a few things:

  • Add to the default comparator a check for defined?(ActiveRecord::Base) and if both objects are AR Base, enter a branch to compare them
  • By default, compare the two objects' attribute hashes
  • Expose a config property like :ignore_active_record_attributes which defaults to created_at and updated_at.
  • I have no idea how to handle associations for this purpose, though.

As an aside, I'm saying "ActiveRecord" here since attributes is defined in AR and not on ActiveModel. In practice I'm more interested in solving for the vast majority of cases rather than trying to build-in a super-smart comparator to serve everyone.

from suture.

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.