On Oct 29, 4:13 pm, "Sindre Aarsaether (somebee)" <[EMAIL PROTECTED]>
wrote:
> I agree that the proposed syntax is a bit quirky. The thought was
> always to have the functions adapter-specific. Ie. dayofweek is a
> native mysql and postgres function, but in sqlite we would convert it
> to something like STRFTIME(created_at, 'D') where D is weekday. Don't
> remember the exact function in sqlite, but you get the idea.
>
> But as I mentioned to, when using this with ambition we can create
> something truly beautiful. Most of the date-methods, string-methods,
> and operators etc can be translated in ambition, so our queries can be
> extremely versatile.
>
> User.all{|u| u.name.length >= 10 && (u.born_at.year - Date.today.year)
>
> > 18 } etc..
>
> So if we find a decent syntax you're good to go? :-)

Sure. I want to keep the underlying Query API separate from anything
like an Ambition-like syntax though.

So while with just raw DM you might use: query = dm.query(User);
query.name.like('%bob%') (obviously a work-in-progress), with an
active_record_finders plugin you could: User.all(like(:name, '%bob%'))
and with a block_finders plugin you could User.all { |user|
user.created_at.year == 2008 }.

The simple justification for the more verbose query-builder is that
it's implementation is both the simplest and most flexible allowing
all the others to be easily built on top and allowing for things like
composed queries passed through several layers that would be much more
difficult with a block syntax.

That's not to say a nicer syntax doesn't become the primary query
method in DM applications. The block form might be the encouraged form
built into dm-core. It just isn't the internal syntax.

That said I'm not a fan at all of the current "pick and choose" DM
layout. Quality suffers, it doesn't really do anything substantive to
encourage loose coupling, and it makes second-class-citizens out of
features that are really core concerns for the majority of
applications (like timestamping, validations, etc). So that will be
going away in the near future as well.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to