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
5
votes
3 answers

how to count the number of rows returned by query in Codeigniter with Datamapper

I am using the following query in controller of codeigniter. $u -> where('us_email_id', $username); $u -> where('us_password', $password1); $details = $u -> get(); $total = count($details); echo $total; echo "
"; echo…
5
votes
1 answer

keys must be strings or symbols

Setup: Ruby on rails 3.2.2 Ruby 1.9.2 dataMapper 1.2.0 mongoid 2.4.8 mongoid_orderable 1.0.0 Getting keys must be strings or symbols error when using mongoid_orderable. I think it has something to do with dataMapper which I am using besides mongid…
Tim Brunsmo
  • 581
  • 6
  • 22
4
votes
2 answers

Proper logging setup for Sinatra + DataMapper

I wonder what's the proper way to set the configure blocks in Sinatra the DRY way. What I want is: When in production, don't show exceptions and errors When in development, log the queries to DB When in testing, use in-memory SQLite db. I've set…
LordTwaroog
  • 1,738
  • 12
  • 23
4
votes
2 answers

Equivalent to find_each in DataMapper

Is there a way to do the equivalent of ActiveRecord#find_each in DataMapper ? (find_each will iterate over the result of a query by fetching things in memory by batch of 1000 rather than loading everything in memory)
mb14
  • 22,276
  • 7
  • 60
  • 102
4
votes
2 answers

PHP Mapper Pattern, many to many relationships

When using the mapper pattern, what is the best practice for defining classes for many to many relationships. For example, let's say we have tables for Products and Categories and Product_Categories Here are some basic skeletons for Products and…
dzm
  • 22,844
  • 47
  • 146
  • 226
4
votes
1 answer

Ruby Datamapper left outer joins

Is there a way to do left outer joins in Datamapper without having to resort to talking to the data-store directly. I've been searching the net and the Datamapper docu with not success on details how to do so.
Juan
  • 89
  • 4
4
votes
1 answer

How do I reset a Datamapper connection after Passenger forks a worker process?

After upgrading several parts of my Rails app (Ruby 1.9.2, Rails 3.0.4, Datamapper 1.1.0) and moving to Passenger Standalone, we started getting weird MySQL connection errors, including: Field-count mismatch Lost connection to MySQL server during…
mltsy
  • 6,598
  • 3
  • 38
  • 51
4
votes
1 answer

Ruby Problem with DataMapper "DataObjects::URI.new with arguments is deprecated..."

When I initialize a string in datamapper 1.1.0 DataMapper.setup (:default, "sqlite://#{ Dir.pwd}/base.db") I get the following error in the Data Mapper: DataObjects:: URI.new with arguments is deprecated, use a Hash of URI components (C: /…
harungo
  • 219
  • 2
  • 11
4
votes
1 answer

How can I better optimize many-to-many association queries with DataMapper?

DataMapper appears to be generating grossly sub-optimal queries for associations that use a join table. What can I do to improve the performance of these queries? Note that it generates the same queries with an implicit join table, as well…
Nevir
  • 7,951
  • 4
  • 41
  • 50
4
votes
4 answers

Datamapper with a Mysql Master/Slave

I cant seem to find any info on how to use datamapper talk to a mysql master/slave setup. I'm running rails3 with dm-mysql-adapter
Anders
  • 41
  • 1
4
votes
1 answer

Missing `test` rake tasks in Rails 3 project based on DataMapper template

How can I get the test tasks back? Backstory: I didn't start with the default new rails project. I'm using datamapper with dm-rails and used their boodstrap command: rails new project_name -m http://datamapper.org/templates/rails.rb My Rakefile…
Larsenal
  • 49,878
  • 43
  • 152
  • 220
4
votes
1 answer

What does passing a class name as a parameter in a function mean?

I am reading zend Framework quick start: There is a function in the Mapper class: public function save(Application_Model_Guestbook $guestbook) { $data = array( 'email' => $guestbook->getEmail(), 'comment' =>…
Tommy Cox Green
  • 633
  • 1
  • 4
  • 20
4
votes
1 answer

Rail3 rake test task not running tests

I have a very similar problem to Mr. Limpens, with one major different: I do include the test_unit railtie into my application.rb. From my application.rb: require File.expand_path('../boot', __FILE__) # Pick the frameworks you want: …
troutwine
  • 3,721
  • 3
  • 28
  • 62
4
votes
3 answers

Model associations using DataMapper in separate files

I'm working with DataMapper and trying to use associations between models Project and Task. I have the models in separate files project.rb and task.rb. When I try associating them with each other I get the following error: Cannot find the…
lobati
  • 9,284
  • 5
  • 40
  • 61
4
votes
1 answer

Ruby Datamapper stored decimals displaying in scientific notation

I have a model, called delivery: property :id, Serial property :created_at, DateTime property :updated_at, DateTime property :price, BigDecimal, :precision => 10, :scale => 2 Delivery has a price, which when viewed in SQLite is…
Neil
  • 297
  • 1
  • 2
  • 5