Skip to content
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

Use Integer class for checking integer instead of Fixnum #62

Merged
merged 3 commits into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ rvm:
- 2.1.8
- 2.2.4
- 2.3.0
- 2.4.0
script: bundle exec rake
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GEM
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
diff-lcs (1.2.5)
json (1.8.3)
json (2.0.3)
parser (2.2.2.5)
ast (>= 1.1, < 3.0)
powerpack (0.1.1)
Expand Down
2 changes: 1 addition & 1 deletion lib/pg_query/deparse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def from(item)

def deparse_item(item, context = nil) # rubocop:disable Metrics/CyclomaticComplexity
return if item.nil?
return item if item.is_a?(Fixnum)
return item if item.is_a?(Integer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a version-check for the Ruby version here?

(this might not be tested by the test suite right now)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works with any version rubies.

  • In ruby 2.3.x or older, Integer class is an ancestor of Fixnum and Bignum.
  • In ruby 2.4+, all integers are Integer class.

So item.is_a?(Integer) works in both cases.
Supporting Bignum in older rubies is a difference, but it may work as intended.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, you are indeed correct!


type = item.keys[0]
node = item.values[0]
Expand Down