Coder Social home page Coder Social logo

Comments (4)

landongrindheim avatar landongrindheim commented on June 3, 2024

I've dug into this a little and would like to pitch in to resolve it 😄

There are a couple of ways this can be addressed, depending on whether #one is considered an appropriate method for HasMany.

If it shouldn't be supported, I can remove it from the docs. I noticed the code in the docs is also in place in the Hanami/Model repository.

Given this block of code...

  def book_for(author, id)
    assoc(:books, author).where(id: id)
  end

... it seems reasonable to assume that there will be one book (since scoping is done on an id). However, if this scoping was done on a non-unique column/attribute, relying on ROM's one method would easily result in a TupleCountMismatchError. Perhaps a #first approach would be better suited to this problem?

from model.

jodosha avatar jodosha commented on June 3, 2024

@mereghost Would you please have a look? Thanks.

from model.

landongrindheim avatar landongrindheim commented on June 3, 2024

I'll provide two solutions to this. One adds the method #one to HasMany (#553), the other removes the documentation from this repository as well as the guides repository (#554) 🙂

from model.

landongrindheim avatar landongrindheim commented on June 3, 2024

@jodosha @mereghost Any thoughts on the solutions referenced above?

from model.

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.