Skip to content
This repository

Don't require dm-aggregates in will_paginate/data_mapper #262

Closed
wants to merge 1 commit into from

3 participants

Reid Beels Don't Add Me To Your Organization a.k.a The Travis Bot Mislav Marohnić
Reid Beels

Not all DM adapters implement the necessary interface for the dm-aggregates plugin, but may instead implement a #count method by other means. Since will_paginate really only needs a working #count method on the DM collection to function, let DM users require dm-aggregates in their own code if they want it.

I've also added a require of dm-aggregates to the DM test connector to maintain the present behavior of that test.

Reid Beels Remove dependency on dm-aggregates in will_paginate/data_mapper
Not all DM adapters implement the necessary interface for the
dm-aggregates plugin, but may instead implement a #count method by
other means. Since will_paginate really only needs a working #count
method on the DM collection to function, let DM users require
dm-aggregates in their own code if they want it.
e81f257
Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request fails (merged e81f257 into 71f793e).

Reid Beels

I'm failing to reproduce the failure travis is reporting locally using 1.8.7 and the Rails 3.0 gemfile. It's a failure related to AR and posgres, so I'd be surprised if this change affected it.

Mislav Marohnić
Owner

If I start requiring people to manually require "dm-aggreggates", that will break their existing apps. I think it's ok for will_paginate to require it if it needs its functionality. Can "dm-aggregates" break anyone's code?

Reid Beels

This is no longer a problem in our codebase, as we've moved away from using DM in the way that was causing our problem. Feel free to close this issue.

Here's a little more context about the edge case that caused me to submit it in the first place, in case anyone else is hitting it:

It broke our code, but I suspect our code was somewhat on the weird side. We were using a fairly minimal custom DM adapter, descending from AbstractAdapter, to talk to an internal API. Our adapter defined a "count" method which made the proper API calls, and including "dm-aggregates" overrode our method with its own "count" method.

All of the methods provided by dm-aggregates rely on the adapter defining an "aggregate" method that handles the construction of aggregate queries. Since this method isn't required for a DM adapter, and didn't really make sense for our use, we hadn't defined it.

Mislav Marohnić mislav closed this September 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 30, 2012
Reid Beels Remove dependency on dm-aggregates in will_paginate/data_mapper
Not all DM adapters implement the necessary interface for the
dm-aggregates plugin, but may instead implement a #count method by
other means. Since will_paginate really only needs a working #count
method on the DM collection to function, let DM users require
dm-aggregates in their own code if they want it.
e81f257
This page is out of date. Refresh to see the latest.
1  lib/will_paginate/data_mapper.rb
... ...
@@ -1,5 +1,4 @@
1 1
 require 'dm-core'
2  
-require 'dm-aggregates'
3 2
 require 'will_paginate/per_page'
4 3
 require 'will_paginate/page_number'
5 4
 require 'will_paginate/collection'
1  spec/finders/data_mapper_test_connector.rb
... ...
@@ -1,5 +1,6 @@
1 1
 require 'sqlite3'
2 2
 require 'dm-core'
  3
+require 'dm-aggregates'
3 4
 require 'dm-core/support/logger'
4 5
 require 'dm-migrations'
5 6
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.