I just came across a similar issue. In my model, I'm using
repository.adapter.select which returns an array of structs. I convert
that to an array of hashes, which may be more digestible for your
purposes. Here's my model:

class MyModel
  include DataMapper::Resource

  storage_names[:default] = 'my_model'
  property :id, Serial, :field => 'my_model_id', :required => true

  def self.find_foo
    rows = repository.adapter.select <<-SQL
      select
        blah blah blah from my_model inner join blah blah blah
    SQL

    new_rows = rows.map { |row| Hash[row.members.zip(row.values)] }
  end

end

It's a Hash[] not a DataMapperCollection, but you if you can convert
it to one, please share your findings with everyone :)

Thanks,
Mark

On Dec 1, 9:33 am, dev2 <[email protected]> wrote:
> I have a very complex query that runs much more efficiently with
> direct repository access.  So it returns a Struct which makes sense,
> but that means my views that use that data have to process as an array
> instead of a DataMapper object.  It would be nice if I could convert
> the Struct to a DataMapper object to have consistency in my views.
>
> Any advice/ideas/etc?
>
> Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to