New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
quick_count convenience method added #42
Conversation
* Added new _quick_query type, as the auto-quoting on a select was breaking the system. * Hard coded to count(*) -- change to count a specific column?
Hey. Was just preparing to implement it in the next few days. |
Seems good. |
I'm a bit cautious whether it's currently too MySQL-specific - do PostgreSQL and SQLite also both return the result with a column named A quick test confirms that MySQL and SQLite do; assuming PostgreSQL does too, I think it's good to merge. Thanks @Casao for your contribution! |
Thank you, @bigpresh. Later tonight I'll do the merge. |
@@ -336,6 +356,8 @@ sub _quick_query { | |||
return $self->selectrow_hashref($sql, undef, @bind_params); | |||
} | |||
|
|||
} elsif ($type eq 'COUNT') { | |||
return $self->selectrow_hashref($sql, undef, @bind_params); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be safer (in case the column name returned isn't exactly COUNT(*)
) and potentially faster, to just say return $self->selectrow_array($sql, undef, @bind_params);
possibly?
(Using it in a scalar context means it returns undef on failure, just like your code is already doing.)
Added a quick_count feature.
I believe this was wishlisted in #13