Skip to content

Commit

Permalink
Add an alias for count in Trilogy::Result
Browse files Browse the repository at this point in the history
It was reported in trilogy-libraries#206 that `size` was not defined.

Looking at the mysql2 implementation `size` is just an alias to `count`

```
  rb_define_method(cMysql2Result, "count", rb_mysql_result_count, 0);
  rb_define_alias(cMysql2Result, "size", "count");
```

[source](https://github.com/brianmario/mysql2/blob/f6a9b68b42a51d1a370403f11eb88527dcb42dc6/ext/mysql2/result.c#L1241-L1242)

This adds an alias for `count` called `size`
  • Loading branch information
nickborromeo committed Nov 20, 2024
1 parent d22ed28 commit 2818244
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contrib/ruby/lib/trilogy/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ def count
rows.count
end

alias_method :size, :count

def each_hash
return enum_for(:each_hash) unless block_given?

Expand Down

0 comments on commit 2818244

Please sign in to comment.