Questions tagged [datamapper]

Architectural pattern for separating application logic from storage.

Objects and relational databases have different mechanisms for structuring data.

The Data Mapper is a layer of software that separates the in-memory objects from the database. Its responsibility is to transfer data between the two and also to isolate them from each other. With Data Mapper the in-memory objects needn't know even that there's a database present; they need no SQL interface code, and certainly no knowledge of the database schema.

Pattern definition: http://martinfowler.com/eaaCatalog/dataMapper.html

1130 questions
17
votes
1 answer

Automatic logging of DataMapper queries

I am working on a simple app in Sinatra with DataMapper. I want to see the queries that DM is created for my various chained finders, etc. I have tried: DataMapper::Logger.new(STDOUT, :debug) in my configure do ... end block in an environment.rb…
kEND
  • 6,149
  • 3
  • 16
  • 13
13
votes
3 answers

Spork and cache_classes problem with rspec, factory_girl and datamapper

I've got a problem with Spork test server. If I set config.cache_classes = false in config/environments/test.rb then specs start to rasie errors. Failure/Error: task = Factory(:something, :foo => @foo, :bar => @bar) …
sparrovv
  • 5,684
  • 2
  • 25
  • 30
13
votes
3 answers

Flask SQLAlchemy Data Mapper vs Active Record Pattern

I have recently started working on Flask and Flask-SQLAlchemy. Coming from Django background I found Flask-SQLAlchmey to be quite complex. I have read that SQLAlchemy implements Data Mapper pattern while Django ORM is based on Active Record…
13
votes
3 answers

Javascript node.js ORM that follows data-mapper pattern

I've been working with active record and data mapper implementations of ORM enough to know the problems with using active record implemented ORM in my large projects. Right now I'm thinking to migrate one of my projects to node.js and trying to find…
pleerock
  • 16,223
  • 14
  • 93
  • 116
13
votes
1 answer

What is the correct way to setup database with DataMapper and Sinatra on production server?

From the DataMapper document, I think there are at least four functions need to be called to have database setup: DataMapper.setup(:default, 'sqlite:///path/to/project.db') DataMapper.finalize DataMapper.auto_migrate! DataMapper.auto_upgrade! In…
Wen
  • 1,066
  • 1
  • 12
  • 26
13
votes
0 answers

_mysql_init not found when using DataMapper

I have a simple MySQL table: % mysql -u rampion dev -e 'describe person' +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra …
rampion
  • 82,104
  • 41
  • 185
  • 301
11
votes
2 answers

Why does active record pattern not work with rich domain models?

I'm reading the architectural patterns chapter of POEAA, and Fowler says that "As the domain logic gets more complicated and you begin moving toward a rich Domain Model (116), the simple approach of an Active Record (160) starts to break down. The…
blacktie24
  • 4,697
  • 6
  • 37
  • 50
11
votes
3 answers

Using the Data Mapper Pattern, Should the Entities (Domain Objects) know about the Mapper?

I'm working with Doctrine2 for the first time, but I think this question is generic enough to not be dependent on a specific ORM. Should the entities in a Data Mapper pattern be aware - and use - the Mapper? I have a few specific examples, but they…
Tim Lytle
  • 17,008
  • 9
  • 59
  • 88
10
votes
2 answers

Handling relationships with the Data Mapper pattern

I am using the Data Mapper Pattern and I am wondering what is the best way to handle relationships with that pattern. I spent a lot of time searching for solutions in Google and Stack overflow, I found some but I am still not completely happy about…
Vincent
  • 101
  • 5
9
votes
1 answer

Adding an ORM to a Sinatra app; Is there an ideal one with less issues and good performance?

I am looking to add an ORM to my existing Sinatra app. I went through Datamapper, Sequel and ActiveRecord though I haven't tried ActiveRecord yet. Datamapper seems easy but I am constantly facing a issue discussed in "What ORM to use in one process…
abhijit
  • 1,918
  • 3
  • 27
  • 38
9
votes
2 answers

How does the ActiveRecord pattern differ from the Domain Object or Data Mapper pattern?

I was looking at DataMapper, which appeared at first glance to use the ActiveRecord ORM pattern. Other people said that it uses the DataMapper and/or the Domain Object pattern. What is the difference between those patterns?
Joe Van Dyk
  • 6,434
  • 7
  • 52
  • 72
9
votes
2 answers

Data Mapper Pattern: Complexe query from Service Layer

I'm sing the Data Mapper Pattern in Zend Framework. This works well so far, but now I got to a point where I need your help/opinion. So let's start with the Code: We got a table with several Persons: CREATE TABLE `persons` ( `id` int(11) NOT NULL…
Matthias Bayer
  • 1,159
  • 1
  • 8
  • 14
9
votes
3 answers

LoadError: no such file to load -- dm-sqlite-adapter

I'm starting my first Sinatra App and I'm trying to use DataMapper. Everything is in the very early stages, as I can't get it to actually create the DB. I get "LoadError: no such file to load -- dm-sqlite-adapter" when I try to visit my page.…
YuKagi
  • 2,361
  • 3
  • 19
  • 26
8
votes
2 answers

database.yml &references not working

We just upgraded our virtual machines to what I thought was an identical ruby configuration (via RVM... Ruby 1.9.2, Rails 3.0.7, DataMapper 1.1.0). The biggest difference was that we went from MySQL 5.0 to 5.1. For some reason, the exact same…
d11wtq
  • 33,252
  • 14
  • 115
  • 186
8
votes
5 answers

What does a Data Mapper typically look like?

I have a table called Cat, and an PHP class called Cat. Now I want to make a CatDataMapper class, so that Cat extends CatDataMapper. I want that Data Mapper class to provide basic functionality for doing ORM, and for creating, editing and deleting…
openfrog
  • 37,829
  • 61
  • 213
  • 364
1
2
3
75 76