Question

Very simple task but I'm confused...

For example I've the class:

class Test
  include DataMapper::Resource
  property :id, Serial
  property :val1, Integer
  property :val2, Integer
end

Is it possible to find all records where val1 = val2 calling Datamapper's #all method?

The

Test.all(:val1 => :val2)

obviously doesn't work.

I want to find solution via #all without direct SQL-query like

repository(:default).adapter.select('SELECT * FROM tests WHERE val1 = val2;')
Was it helpful?

Solution

You could try something like this:

Test.all(:conditions => ['val1 = val2'])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top