#480 ✓not-applicable
Dirkjan Bussink

Finders should support associations properly

Reported by Dirkjan Bussink | July 24th, 2008 @ 01:38 AM

It should be possible to do the following:

Address.all(:person => Person.first)


Address.all(Address.person => Person.first)

Currently someone has to do something like:

Address.all(Address.person.id => Person.first.id)

This is not only ugly, but also problematic for stuff like composite keys. Furthermore, the user has to handle stuff like Person.first being nil, which should also work automatically.

Comments and changes to this ticket

  • Dirkjan Bussink

    Dirkjan Bussink July 24th, 2008 @ 01:32 PM

    Seems close to working btw, it fails on:

    NoMethodError in 'CostCenter with regard to generating timecards should be able to retrieve all registrations for a certain cost center'

    private method `gsub' called for nil:NilClass

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/adapters/mysql_adapter.rb:21:in `quote_column_name'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/adapters/data_objects_adapter.rb:375:in `original_property_to_column_name'

    /Library/Ruby/Gems/1.8/gems/dm-aggregates-0.9.3/lib/dm-aggregates/adapters/data_objects_adapter.rb:58:in `property_to_column_name'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/adapters/data_objects_adapter.rb:324:in `condition_statement'

    /Library/Ruby/Gems/1.8/gems/dm-core-0.9.3/lib/dm-core/adapters/data_objects_adapter.rb:322:in `map'

    This is because the property in there is a DataMapper::Query::Path and not a Property object.

  • Jonathan Stott (namelessjon)

    Jonathan Stott (namelessjon) November 30th, 2008 @ 09:14 AM

    • Milestone cleared.
    • State changed from “new” to “open”
    • Assigned user cleared.
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) January 8th, 2009 @ 04:41 AM

    • State changed from “open” to “accepted”
    • Assigned user set to “Dan Kubb (dkubb)”
  • Justin Smestad

    Justin Smestad January 15th, 2009 @ 07:55 PM

    +1 for this

    @users = User.all(User.shortcode.id.not => nil)

    class User has 1, :shortcode end

    class Shortcode belongs_to :user end

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) February 21st, 2009 @ 04:05 AM

    • State changed from “accepted” to “not-applicable”

    This is a duplicate of #354.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Referenced by