-
Notifications
You must be signed in to change notification settings - Fork 88
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
Add #count #137
Add #count #137
Conversation
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.
thank you @maiha
count = {{ model_constant }}.count | ||
count.should eq 2 | ||
end | ||
end |
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.
❤️ this spec, thanks @maiha
src/granite_orm/querying.cr
Outdated
@@ -92,6 +92,11 @@ module Granite::ORM::Querying | |||
end | |||
end | |||
|
|||
# count returns a count of all the records | |||
def count : Int64 |
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.
No objection here but why did you choose Int64
?
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.
I was thinking about handling large tables like 10 billion data.
However, in this case, special queries such as CAST AS BIGINT
may be required. In fact, there are no rare cases beyond Int32
at this moment.
So I'd like to modify it to use Int32
. Thought?
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.
I have no preference. I think Postgres might return a different type depending on how much data comes back, so that may be an issue.
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.
Yep, I will choose Int32
and fix it immediately when there is a problem! 😄
I need
count
anyway 😄Best regards,