#1342 suggestion
Kevin Watt

add new AR compatibility methods?

Reported by Kevin Watt | June 27th, 2010 @ 02:51 PM

Pretty simple, and might help with ppl switching between methods:

module DataMapper
module Model

def table_name(v) storage_names[:default] = v.to_s end

#AR-style scoping of queries - any others needed?
def limit(z) all(:limit => z) end
def order(z) all(:order => [z]) end
def where(z) all(:conditions => z) end

end end

Comments and changes to this ticket

  • Martin Gamsjaeger (snusnu)

    Martin Gamsjaeger (snusnu) June 27th, 2010 @ 07:47 PM

    • State changed from “new” to “suggestion”

    Kevin,

    There's a dm-ar-finders gem [1] that already contains a compatibility layer for AR. The methods you mention seem to fit in there. I wonder what's the best way to provide them if we were to. Put them into a module for people to include explicitly if they want, or just include them by default when dm-ar-finders gets required. I'm not sure.

    [1] http://github.com/datamapper/dm-ar-finders

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) July 28th, 2010 @ 01:05 AM

    Yeah, I definitely want to keep all monkey patching of DM in separate plugins.

    There are many cases where I disagree with AR's API design and I would not want to pollute DM with methods to provide compatibility.

    However, I actually don't mind the idea being the query short-hand methods. I've used them in AR and quite liked them. Although I do not like some of the names (I think they're too SQL-y), I wouldn't be opposed to names that match the current names of the DM::Query options.

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 »

Pages