datamapper

Foreign key name in DataMapper associations

I'm currently working on a new app based around an existing database, making use of DataMapper for the data access. However, its conventions when dealing with foreign keys are not what the database uses. Example: class Invoice include DataMapper::Resource storage_names[:default] = 'invoices' property :id, Serial # ... more pr...

Simplifying an inequality for an SQL query.

For reference, this question was boggled, so thanks to everyone who helped unboggle it. I'm trying to locate potential collisions of events in a booking program where events have varying lengths. (a ≤ x && e ≥ y) || (a ≥ x && e ≤ y) || (a ≤ x && e ≤ y) || (a ≥ x && e ≥ y) I'm using DataMapper to accomplish this, but the query I had be...

Who should establish the relationship? The Entity or the Data Mapper?

There are four classes: StudentBase, CourseBase and StudentDataMapper, CourseDataMapper An Student object can have a relationship with an Course object. One Student can have many courses. One course can be visited by many students. In the ER diagram, a Student entity has an attribute called "courses", but a course does not know anyth...

How do I do an Intersection of many<-->many DataMapper Collection?

I am trying to return an intersection of datamapper collections relating to tagged topics. Before we go any further I should point out the obvious: @tags = Tag.all(:title => ["shim", "sham"]) @tags.topics This returns a UNION which means I get all topics with either 'shim' or 'sham' as a tag. What I want to do is return all articles...

datamapper secondary key

Hello, I am using datamapper in a ruby application and I'm facing a problem I do not understand. I have a Appartment model and a Location model. An appartment is at a given location and several appartments can be at the same location. This typically described a 1-n relationship (I guess :-) ) My feeeling is that in the Appartement sql ...

When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying

A colleague of mine is currently designing SQL queries like the one below to produce reports, which are displayed in excel files through an external data query. At present, only reporting processes on the DB are required (no CRUD operations). I am trying to convince him that it would be better to use a ruby ORM in order to be able to di...

Are there any authentication plugins that work with DataMapper?

I'm in need of an authentication method that works with DataMapper. I can see that the authlogic plugin requires the fields crypted_password, password_salt, persistence_token in the User model. Is it enough to just add these fields to the User model definition using DataMapper? ...

What DataMapper plugin gives :null property option

I'm trying to adapt a piece of code that has: property :email, String, :index => true, :null => false, :length => 1000 in the model definition. I'm getting this error: ArgumentError: options :null are unknown from /usr/lib/ruby/gems/1.8/gems/dm-core-0.10.2/lib/dm-core/property.rb:901:in `assert_valid_options' from /usr/lib/ruby/ge...

Is it possible to have ActiveRecord and DataMapper use the same database in the same app?

I'm in the process of replacing ActiveRecord with DataMapper in one of my apps. Since there aren't any authentication solutions that are compatable with DataMapper, I'm thinking that I could use ActiveRecord just for user authentication, and then use DataMapper everywhere else. I'd like to have both ORMs interacting with the same databas...

Can DataMapper properties appear in multiple composite indexes?

I found that this issue had been discussed in Ticket #58 of DataMapper, apparently way back in 2007, but I can't find how to do it in the latest version (dm-core-0.10.2). I want to define two composite indexes, each of which are partially based on a certain property. I was hoping I could do this... class Stat include DataMapper::Resou...

Problem with CodeIgniter. DX_Auth not working when deployed...

So we're currently using CodeIgniter + DataMapper OverZealous Edition + DX Auth. It is working on our local machines, as well as our staging server. As soon as we push to their server though, the login doesn't work at all. Upon further investigation, the data from the form is not coming in to the controller where we do our authenticat...

Do something after creating, and before destroying

How can I have a block execute whenever an instance of a DataMapper class is a created, and another before it is destroyed? ...

Datamapper (ruby) - (Using the blog example) Getting the posts that don't have comments

Hi there, First SO question after using this place for reference on a lot of other things.. I'm nervous. DataMapper.. Using Blog model for example (posts, comments etc - http://datamapper.org/docs/associations.html) I'm trying to workout how to get the blog posts that don't have any comments.. So something like Post.all(:comments => {...

Looking for records of the current month with a DataMapper query

Hi, I'm trying to reproduce this SQL query I used with ActiveRecord: Post.all(:conditions => ["EXTRACT(MONTH from created_at) = ? AND EXTRACT(YEAR from created_at) = ?", month, year]) But since I'm converting everything to DataMapper I was looking for a way to do this... Can anyone help? ...

PHP what is the best approach to split these values up?

Hi all, Having a hard time with this one as I don't think I know all of my options. I have to parse a free form text field that I need to map the values to a database. Here is some example text, NOTE: not all fields have to be there, not all delimiters are the same and not all descriptors are available. I do need to check if the value ...

DataMapper and Codeigniter - how to fully manage a many-to-many relationship

I have the following relationship CType has many Field Field has many Ctype and of course the tables used are fields, ctypes, and ctypes_fields. Normally, the ctypes_fields table should contain only ids referencing the other two tables. However, i'd like to put there a "options" field that will contain some content for the concrete in...

Performance gain or less using an association table even when there is just a one-to-many relationship

I am going to build a PHP web application and have already decided to use Codeigniter + DataMapper (OverZealous edition). I have discovered that DataMapper (OverZealous edition) requires the use of an extra association table even when there is actually just a one-to-many relationship. For example, a country can have many players but a ...

Editing records with SQLite, DataMapper, and Sinatra.

I'm in the process of learning Sinatra and DataMapper. To do so, I've been playing with a "customer database" project. Creating and deleting records is trivial and now I'm working on editing records. So far I've managed to piece together a form in my views and a couple of routes that I thought would edit a record. Here's some code ...

Datamapper doesn't save data into database

Hi! I'm writing a simple application with Sinatra and Datamapper in Ruby and I have a trouble — when I try to save data into my SQLite database nothing is changing. But when I try to install database or change data from irb it works perfectly. Here is my Datamapper's setup, model and database installing method (this works fine): DataM...

How to get DataMapper resource serial and key attributes in Ruby ?

Hey guys I`m trying to figure out how to get serial and key attributes set for Resource object. Basic method DataMapper::Resource.attributes returns a collection of properties, but it does not say anything about types. Of course i can check it via system call: obj.class, but cant understand how to get type information from resource inst...