awesome-print / awesome_print

Pretty print your Ruby objects with style -- in full color and with proper indentation
http://github.com/michaeldv/awesome_print
MIT License
4.08k stars 454 forks source link

ArgumentError is displayed when trying to print Sequel Dataset #196

Closed xtagon closed 8 years ago

xtagon commented 9 years ago

Hi,

I found an issue in a Rails project with Sequel-Rails, Pry-Rails, and AwesomePrint. I had more Pry plugins loaded, but took them all away to narrow down AwesomePrint's involvement.

When I run the following in the REPL without AwesomePrint, the expected output is returned:

[1] pry(main)> Sequel::Model.db["select version()"]
=> #<Sequel::Postgres::Dataset: "select version()">

However, if I use AwesomePrint, I get the following:

[2] pry(main)> ap Sequel::Model.db["select version()"]
ArgumentError: wrong number of arguments (0 for 1..2)
from /home/xtagon/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/sequel-4.21.0/lib/sequel/dataset/actions.rb:686:in `to_hash'

It looks like the issue is that Sequel::Postgres::Dataset implements its own #to_hash method, but it takes 1..2 arguments and AwesomePrint doesn't know, tries to send it zero args.

Is this something you guys would like to look into? Should it be Sequel's responsibility instead? Doesn't make a difference to me, I can live with it personally, but figured I should report to someone.

Regards, Justin

mrageh commented 9 years ago

I've just come across this same issue, should the problem be addressed here or in sequel?

michaeldv commented 9 years ago

Since standard to_hash in Ruby has no arguments I would expect Sequel to make their version compatible with Ruby's.

mrageh commented 9 years ago

Ok I'll open an issue on sequel

bjmllr commented 9 years ago

Sequel::Dataset#to_hash might be more intrusive than you want. #to_hash will actually perform the SQL query against the database, unlike #inspect or #sql. It seems that the arity checking that was added in https://github.com/michaeldv/awesome_print/commit/4ee2ade5f72677e2afd92033e6f0d4c244a8e43d (not yet released) will prevent this error from appearing; after that change, AwesomePrint will use #inspect rather than #to_hash for datasets. If you do want to see the result of the query you could try ap db["select version()"].all.

waldyr commented 8 years ago

Thanks for using awesome_print.

I'm marking this, #202 and #204 as resolved. Tested with 1.7.0 and it works properly.

screen shot 2016-06-19 at 1 15 11 pm

Sorry for the late response.

As always, if anybody is still running into this issue on the latest build, then please tag me or @gerrywastaken and we will take care of it.