Hi Ted,

Thanks for the kind responses and the acknowledgment of Datamapper
shortcomings. The final answer was not without problems, however:

1. Like queries on the output of find_by_sql are not upcased
automatically, which means they are case sensitive
2. DM-Pager doesn't really work on raw queries that return less than
the full model. Which means it gives wrong total count and total page.

After seeing this post from Dan Kubb delving deeper into the problems
with raw sql in dm (and somewhere he mentioning his project Veritas),
we took his suggestion looked into Sequel, which is pretty strong in
raw sql (and kinda pales in comparison to DM in pure rubyness and
automatic migrations). Sequel's pagination is even from an extension
buitin into the gem, and is also really powerful.

So yes, out of 40 queries, there is one that Datamapper doesn't do, IF
it has pagination, and failure is on the pagination plugin side, not
on DM. This is very solid. We also never expect DM to handle this
custom queries at all. These are not relational data at all, we are
just using DM for simplicity, and the fact that we are still in closed
beta stage, and no need for really powerful/horizontal scalable search
engines/NOSql databases.

As things go, I'll consider this blog post (I am still finishing a
write up on Coffeescript, Clamato and Cappuccino, so let's see how
time let's me do them all). It will probably involve the beginning of
the story, including the myriad of troubles Active Record gave us (we
never locked back, thanks to this group, which helped us with the
toughest questions). But I'll let Sequel sink in more, so that I can
tell a more complete story (hands on Datamapper, Active Record and
Sequel).

But if more people need more details, possibly an example, i'll be
glad to show/write them.

Regards,
- Daniel Ribeiro

On Sep 14, 9:56 pm, Ted Han <[email protected]> wrote:
> Hey Daniel,
>
> Sorry i totally missed your previous replies!
>
> I'm glad to hear that it (sort of) worked for you.  The sorting on queries
> is indeed one of DM's shortcomings for SQL backends at the moment.  There is
> some work afoot, and an endpoint for generating query objects for a specific
> backend (or set of backends), that may make this sort of thing possible (and
> easy).
>
> It would be awesome to see a write up on this subject, just so if people
> encounter this, they know how you solved it!  This would make a great blog
> post :D
>
> -Ted
>
> On Tue, Sep 14, 2010 at 8:30 PM, Daniel Ribeiro <[email protected]> wrote:
> > Actually Ted, it does work, even with limit and offset, provided you
> > add a dummy field that is computed on the sql query, and is null for
> > all instances, but yes, it does work.
>
> > The gem Sequel has more support for these things, but for the time
> > being, it will do.
>
> > Thanks again.
>
> > On Sep 13, 2:31 am, Daniel Ribeiro <[email protected]> wrote:
> > > Actually, spoke a bit too soon. The paging works, however, it messes
> > > up ordered results. Which is really sad when the order is defined by a
> > > sql function, and not a field of the model.
>
> > > Well, guess adapting the paging will be the only way out....
>
> > > On Sep 13, 2:21 am, Daniel Ribeiro <[email protected]> wrote:
>
> > > > Thank you a lot. It works great after a simple find_by_sql. It will
> > > > not work on queries that do not return models, but so far so good. By
> > > > the time we need to return something other than models, we will be in
> > > > so much trouble that we will probably have to look into mongodb/riak/
> > > > couchdb, and paging will be the least of our problems.
>
> > > > Great tip!
>
> > > > On Sep 13, 12:25 am, Ted Han <[email protected]> wrote:
>
> > > > > Hey Daniel,
>
> > > > > I haven't seen/used dm-pager, but if it functions on collections in
> > memory,
> > > > > the dm-ar-finders wrap the results from SQL queries.  If however it
> > relies
> > > > > on addind the limit and offset flags for a query, this won't work.
>
> > > > > On Sep 12, 2010 11:08 PM, "Daniel Ribeiro" <[email protected]>
> > wrote:> We use dm-pager to do pagination, and it has worked wonders so far.
> > > > > > However, it doesn't work on direct queries made through
> > > > > > repository.adapter. Is there another plugin/fork that enables it?
>
> > > > > > --
> > > > > > 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]<datamapper%[email protected]>
> > <datamapper%[email protected]<datamapper%[email protected]>
>
> > > > > .> For more options, visit this group at
>
> > > > >http://groups.google.com/group/datamapper?hl=en.
>
> > --
> > 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]<datamapper%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/datamapper?hl=en.

-- 
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