On Tuesday, September 16, 2014 2:12:48 AM UTC-5, Куракин Александр wrote:
>
> Good day!
>
> I have some queries in my code, i.e. 
> *Comment.dataset.group_and_count(:creator_id).all* or some *join*s. These 
> queries return *Comment* but nor dataset nor hash.
>
> But I don't want to initialize a model at all. Because of hooks, plugins, 
> etc. start to work. So, I do *DB[query_above.sql].all* and it returns a 
> dataset.
>
> So I have two questions:
>
> 1) Is there some standard method to avoid initializing a model during 
> query?
>
> 2) Is this behavior correct? Well for *join* it is correct because of SQL 
> query has *SELECT `comments`.**, but for *group_and_count*?
> What's the logic (to understand)? *Comment*'s methods always return 
> *Comment*?
>
> Thanks!
>

Hi

If you don't want model instances to be created then you can do

DB[:comments].group_and_count(:creator_id).all

which will return an array of hashes.

But it seems there is a more fundamental problem if you are using models 
but don't want instances to be created. If you can provide a self contained 
example that illustrates the issue, perhaps we can provide a solution.

Thanks, Rohit

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to