newbie questions

620 views
Skip to first unread message

Perry Smith

unread,
Nov 30, 2012, 9:41:22 AM11/30/12
to datam...@googlegroups.com
Hi Guys,

I keep looking at DataMapper but I get scared (or lazy is probably more accurate).

I have an existing Rails 3.2.8 project that is not yet deployed.  I decided a few weeks ago to somewhat start over and use BDD (cucumber, rspec, etc) to "drive" a major reworking of the project.  The main purpose of the project is a place for me to learn.

I'm also reading various books and articles like Objects On Rails and Clean Ruby that prompt me to decouple the database from the business logic.  I've been lead to believe that DataMapper is a better than ActiveRecord for this.

I've also bumped into a couple posts that DataMapper 1.2 isn't compatible with Rails 3.2.8 so the beta version needs to be used.  That doesn't bother me but I'm hoping to get some good directions on how to make the move from ActiveRecord to DataMapper in my current situation.

Thank you
Perry

solnic

unread,
Dec 1, 2012, 8:30:28 AM12/1/12
to datam...@googlegroups.com
Hey Perry,

DM1 implements Active Record pattern so there's no big difference between DM1 and ActiveRecord in Rails from the app's design point of view. You *can* separate persistence concerns from domain logic using either DM1 or AR; however, it adds a lot of extra work so you should really think if that's what you need.

It's also probably worth to mention that DM1's development is no longer very active. We're busy working on the next major version of DM which implements Data Mapper pattern and that's probably something you're looking for unfortunately it's not finished yet.

If you want to learn about DM 2.0 you can check out my slides from RubyShift conf: https://speakerdeck.com/solnic/datamapper-2-an-object-mapping-toolkit

DM1, given its stale development, is not really a good choice IMHO. ActiveRecord has much better support in Rails and you can face various integration issues when using DM1 (no matter how much I hate to admit that heh). It is also a big unknown when and even IF we're going to release DM 1.3.0.

Hope this helps.

Cheers!

# solnic

Perry Smith

unread,
Dec 1, 2012, 10:17:10 AM12/1/12
to datam...@googlegroups.com

On Dec 1, 2012, at 7:30 AM, solnic wrote:

> Hey Perry,
>
> DM1 implements Active Record pattern so there's no big difference between DM1 and ActiveRecord in Rails from the app's design point of view. You *can* separate persistence concerns from domain logic using either DM1 or AR; however, it adds a lot of extra work so you should really think if that's what you need.
>
> It's also probably worth to mention that DM1's development is no longer very active. We're busy working on the next major version of DM which implements Data Mapper pattern and that's probably something you're looking for unfortunately it's not finished yet.
>
> If you want to learn about DM 2.0 you can check out my slides from RubyShift conf: https://speakerdeck.com/solnic/datamapper-2-an-object-mapping-toolkit

Thank you immensely. Things make much more sense now. It was DM 2.0 that was being mentioned in the other sources.

Is it too early to use DM 2? As I said, my current project is mostly to learn. I'd be more than happy to piddle and play and provide some feedback. I usually use Postgres

Thank you again,
Perry

solnic

unread,
Dec 1, 2012, 11:31:46 AM12/1/12
to datam...@googlegroups.com

It is too early. If things go well we will release an alpha in December and it'll be perfect time for testing things out and providing feedback :)

Currently development takes place in https://github.com/solnic/dm-mapper and https://github.com/mbj/dm-session.

cheers

# solnic

Perry Smith

unread,
Dec 1, 2012, 11:34:37 AM12/1/12
to datam...@googlegroups.com

On Dec 1, 2012, at 10:31 AM, solnic wrote:
>
> Currently development takes place in https://github.com/solnic/dm-mapper and https://github.com/mbj/dm-session.

By the way, the session looks very similar (to me) to Context in DCI. I'm liking a lot of what I'm seeing. Good luck!

david_h...@brown.edu

unread,
Apr 5, 2013, 6:58:16 AM4/5/13
to datam...@googlegroups.com
Hello, 

I'm considering using datamapper 1.2 on a project. 

However, I'm curious what are the "various integration issues" that might be encountered when using DM 1.2? (See reference below, from December).
Have those issues been resolved?


On Saturday, December 1, 2012 8:30:28 AM UTC-5, solnic wrote:

It's also probably worth to mention that DM1's development is no longer very active. We're busy working on the next major version of DM which implements Data Mapper pattern and that's probably something you're looking for unfortunately it's not finished yet.

DM1, given its stale development, is not really a good choice IMHO. ActiveRecord has much better support in Rails and you can face various integration issues when using DM1 (no matter how much I hate to admit that heh). It is also a big unknown when and even IF we're going to release DM 1.3.0.

# solnic

Piotr Solnica

unread,
Apr 5, 2013, 7:07:16 AM4/5/13
to datam...@googlegroups.com
On Friday, April 5, 2013 at 12:58 PM, david_h...@brown.edu wrote:
Hello, 

I'm considering using datamapper 1.2 on a project. 

However, I'm curious what are the "various integration issues" that might be encountered when using DM 1.2? (See reference below, from December).
Have those issues been resolved?
Various gems working with multiple ORMs have better support for AR than DM1. It's just easier to work with AR than DM1 because it has better support in the community. We've shifted focus on DM2 so DM1 is being EOLed.

Cheers

# solnic

Harrison, David

unread,
Apr 5, 2013, 7:09:30 AM4/5/13
to datam...@googlegroups.com
Thanks very much for the response. 

So there are no specific integration issues, but simply much better support for AR? 

Best,
David



# solnic

--
You received this message because you are subscribed to a topic in the Google Groups "DataMapper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/datamapper/UCHC5TF6I0M/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to datamapper+...@googlegroups.com.
To post to this group, send email to datam...@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
David Harrison
Lead Developer Analyst
Computing & Information Services
Brown University
401-863-7455





kristian

unread,
Apr 5, 2013, 7:10:44 AM4/5/13
to datam...@googlegroups.com
I need to add my two cents. I am currently moving 2-3 three little application from AR to DM1 using rails and once that is done the next step is to move from rails to cuba. all problems on the way could be solved so far.

- christian

Chris Corbyn

unread,
Apr 5, 2013, 7:26:31 AM4/5/13
to datam...@googlegroups.com
Here's my $0.02. We're currently in the middle of the huge refactor to remove DM1 from our app and switch over to ActiveRecord. We've been using DM1 for about 18 months at this point.

    - DM1 is not being actively developed. Discussion with the core contributors on Twitter came to the conclusion that support for it has ceased and there are no plans to maintain the code any further (https://twitter.com/dkubb/status/304315005619273728)
    - Even Pull Requests are not being actioned at this point (https://github.com/datamapper/dm-core/pulls)
    - DM2 is quite different to DM1, and the release date is still unknown. Either way, moving from DM1 to DM2 is going to be painful in a large app.
    - Because DM1 is not maintained, issues are beginning to crop up with common dependencies (e.g. multi_json, addressable) that hold back the entire project (https://github.com/datamapper/dm-core/issues/216).
    - You'll run into issues with many Rails gems assuming you're using ActiveRecord. This hasn't been a huge issue for us, as many gem authors have begun to support other ORMs, but it does throw some hurdles in front of you.
    - Some things that "should" work in DM1 don't work, and don't work in fairly serious ways e.g.
      * (Model.all( … ) | Model.all( … )).all( … ).destroy (incorrectly deletes all records from the table)
      * Models can fail to save due to validation errors on related models, which are *extremely* difficult to track down.
    - Currently DM1 isn't compatible with Ruby 2.0… in light of the ceased development, this is a problem for us.

I think if you're starting a new Rails project, you would do well to just use ActiveRecord and avoid a world of pain trying to use DM1 as it currently stands ;)


--
You received this message because you are subscribed to the Google Groups "DataMapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datamapper+...@googlegroups.com.

Chris Corbyn

unread,
Apr 5, 2013, 7:27:34 AM4/5/13
to datam...@googlegroups.com
You're nuts, sorry ;) You're moving to a dead project from an actively developed one.

Il giorno 05/apr/2013, alle ore 22:10, kristian <m.kri...@web.de> ha scritto:

I need to add my two cents. I am currently moving 2-3 three little application from AR to DM1 using rails and once that is done the next step is to move from rails to cuba. all problems on the way could be solved so far.

- christian


Harrison, David

unread,
Apr 5, 2013, 9:31:26 AM4/5/13
to datam...@googlegroups.com
Thanks very much for the detailed response.  This is very helpful.

Did you consider other Ruby ORMs, like Sequel, rather than ActiveRecord?   http://sequel.rubyforge.org/
If so, I'd appreciate your thoughts on why you chose to go with ActiveRecord instead.

Best,
David


--
You received this message because you are subscribed to a topic in the Google Groups "DataMapper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/datamapper/UCHC5TF6I0M/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to datamapper+...@googlegroups.com.

To post to this group, send email to datam...@googlegroups.com.
Visit this group at http://groups.google.com/group/datamapper?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chris Corbyn

unread,
Apr 5, 2013, 9:50:04 AM4/5/13
to datam...@googlegroups.com
You're welcome.

Initially we adopted DM since we needed to fit Rails around our legacy database schema and didn't want to take the hit of having to migrate large parts of our schema (which is accessed by a PHP app and a Rails app, both of which are large). DM helped us greatly in that regard, since it lets you map table names and column names cleanly. We're losing that benefit by leaving DM, but we're just going to get our schema more in line with how AR wants it, over a period of time.

We could have gone with Sequel instead, but DM's DSL looked more appealing to us. I still think that now. The reason we've decided to move towards AR and not Sequel at this point is really just about compatibility and long-term support. As a business needing to keep our product up to date, we don't want to find ourselves backed into the same corner we got backed into by choosing to use DataMapper, and using ActiveRecord just means we're ensuring we're using a project that is actually going to be maintained for as long as Rails is maintained. In short, it's just more practical.

Abe Voelker

unread,
Apr 5, 2013, 10:35:05 AM4/5/13
to datam...@googlegroups.com
If it's for a greenfield project with no existing database(s), I'd suggest using ActiveRecord for the reasons that Chris mentioned.  However, I still think that DataMapper shines when you have an existing (legacy) database schema that you can't change that you want to write models for.

ActiveRecord assumes that it controls the schema, so it wants to put an auto-incrementing PK on every table, use its own naming conventions for tables and fields, and needs migrations to keep track of model attributes (the attributes aren't defined in the model).  DataMapper on the other hand works well with legacy schemas - you can tell it to use composite primary keys, use custom table and field naming conventions, and you never have to run migrations.  It's true that you can coerce ActiveRecord into some of these things, but you are essentially hacking/fooling it do to so (perhaps this has gotten better in recent times, like now that it uses ARel, but a few years ago it was a huge PITA).  I don't have any experience with Sequel so can't comment on it.
Reply all
Reply to author
Forward
0 new messages