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

1134 questions
0
votes
2 answers

Tables in DataMapper w/ Rails not Inheriting Correctly

I'm using DataMapper in Rails, replacing ActiveRecord and am trying to do some single table inheritance. The problem is, sqlite3 seems to be reading all of my inherited tables weird, and so I get some strange errors when trying to create an instance…
thejava
  • 108
  • 2
  • 10
0
votes
1 answer

DataMapper has n with conditions

By any chance is it possible to create a conditional association with DataMapper? For example: I want the User have n Apps just if that user have the attribute :developer => true something like this: class User include DataMapper::Resource …
zanona
  • 12,345
  • 25
  • 86
  • 141
0
votes
1 answer

How to escape the less than symbol for SQL insertion in DataMapper

I'm trying to insert a value with a < symbol in it, but each time, it just cuts off the remainder of the string: winecheap = Tag.first_or_create(:tag_type => tt, :value => "Wine & Spirits <$65") DEBUG - (0.000828) SELECT "uuid", "created_at",…
joslinm
  • 7,845
  • 6
  • 49
  • 72
0
votes
1 answer

How can I get "x" objects before a given object?

It's better to explain this in pseudo-code, I want to do this: limit_object = Model.first(id: bla) objects = Model.all(constraint: limit_object, limit: 30) If the objects are: [a, b, c, d, e, f, g] and limit_object is 'c', it should return: [a, b,…
Mert Dümenci
  • 493
  • 1
  • 5
  • 18
0
votes
1 answer

Sinatra / Datamapper: parsing table forms

I have a table-based form with which I intend to enter data into my application. Each is dynamically added through Javascript for every item I want to add. However, I cannot figure out how to manage posting the data. For example, I have…
Nekkoru
  • 1,145
  • 2
  • 12
  • 18
0
votes
1 answer

How to convert Rails 3.2 datamapper validation to activerecord?

I have a rails 3.2 app using datamapper validations that I need to convert to active record. The existing code looks like this: validates_with_method :quota I tried the same thing with active record and my rspec test crashes with: `method_missing':…
David Watson
  • 3,394
  • 2
  • 36
  • 51
0
votes
2 answers

Where should I place DO property checks that require input from other objects?

I am trying to get my head around the structure of domain objects, data mappers and services, I am however struggling to grasp exactly what goes where. This question is very similar, but does not have an answer that helps. Should methods that…
0
votes
1 answer

DataMapper `has n` for different types of a model

I would like to have a model with different types of has n, for example: class Blog include DataMapper::Resource property :id, Serial has 1, :owner # of type user... has n, :authors # of type user... end class User include…
tekknolagi
  • 10,663
  • 24
  • 75
  • 119
0
votes
1 answer

Unflattening view data to JSON with Mule DataMapper

I've got a database view that I need to send to a Web API call in JSON format, but I'm having a hard time figuring out how to get the datamapper to un-flatten the data. The format I want to get to is something like: { "PersonId": "12345" ,…
Becca Dee
  • 1,530
  • 1
  • 24
  • 51
0
votes
0 answers

How to Modify the Linq to Sql mapping using the same DataContext instance?

After trying this kind of things: How to add property-level Attribute to map ColumnAttribute at runtime? I've find another problem. The reason it's because I want to reuse the same instance of DataContext. But when I want to refresh DataContext…
lorddarkangel
  • 212
  • 3
  • 21
0
votes
1 answer

DataMapper get results with join

I'm working on a demo app to evaluate CodeIgniter for a new project. We are currently reviewing the DataMapper ORM Library - http://datamapper.wanwizard.eu I've hit a problem that seems odd: I cannot get values from 2 joined tables in one return. I…
gkl
  • 199
  • 2
  • 11
0
votes
1 answer

Datamapper transaction doesn't rollback

I have such code: Vhost.transaction do domains.each do |domain| unless domain.save errors << domain.errors end end unless vhost.save errors << vhost.errors end end I expect a rollback if any domain.save or vhost.save…
ciembor
  • 7,189
  • 13
  • 59
  • 100
0
votes
1 answer

DataObjects::SyntaxError Help Needed: Ruby, Sinatra, & DataMapper

I'm putting together my first Sinatra application and I'm having issues with the database relationships. I've tried everything I know how to do on this (not much) and I'm still scratching my head. Here's the error I keep getting: …
0
votes
1 answer

Datamapper, Ruby: maintaining ID consistency?

I'm writing a simple application using DataMapper. It is somewhat crucial that I maintain consistent IDs (serial property) in my database (which may change freely), so I wrote this simple script that goes through every record and fixes the IDs so…
Nekkoru
  • 1,145
  • 2
  • 12
  • 18
0
votes
1 answer

How to add property-level Attribute to map ColumnAttribute at runtime?

From this question we have implemented the ColumnAttribute association with the corresponding property, but when Linq to SQL tries to map this property to a Column it doesn't work. Our property and mapping code(from the other question): public…
lorddarkangel
  • 212
  • 3
  • 21