Fix various issues under ruby 1.9. #7

Closed
wants to merge 2 commits into
from

Projects

None yet

2 participants

@rwjblue
Contributor
rwjblue commented Aug 19, 2011

Under 1.9 the yaml library doesn't add the is_binary_data? method to String. This pull request fixes that issue.

Also, there are errors and deprecation notices from calling Object#type under 1.9 (under 1.8.7 it works the same as Object#class). These errors and deprecations were being caused because Statement#execute returns nil if the result is void?. This was causing the following errors in the test suite:

  2) execute when performing keyspace operations should set keyspace without compression
     Failure/Error: Statement.new(handle, "use keyspace1").execute
     NoMethodError:
       undefined method `type' for nil:NilClass
     # ./lib/cassandra-cql/result.rb:17:in `void?'
     # ./lib/cassandra-cql/statement.rb:51:in `execute'
     # ./spec/statement_spec.rb:25:in `block (3 levels) in <top (required)>'

All tests pass (with the exception of a single pending test) under 1.9.2-p290 after this pull request and issue #6.

@kreynolds

I had originally written it this way but it became awkward to test for nil all the time when returning nil instead seemed appropriate in all cases. Why do you prefer it this way?

Owner

That's not actually supposed to be calling Object#type at all .. type is an attribute of a CassandraThrift::CqlResult. If you look in the fixtures, it specifies type in result_for_void_operations.yml and it should be referring to that. I don't know why in 1.9 it seems to want to ignore that. That's why I check to see if it's void?, meaning the type == 2, and return nil if so.

@kreynolds
Owner

It looks like the code itself is fine and the spec was incorrectly returning nil instead of a VOID resultset. I've updated the tests to hopefully remove those errors for you. Run this in your environment and see if that fixes the nil trouble you were having.

@rwjblue
Contributor
rwjblue commented Aug 19, 2011

The specs all pass properly using 1d762f0 (current HEAD of master branch). Now the only test failures that I have are related to calls to String#is_binary_data? (commit ca0559c) and the Time precision issue (that is being fixed in SimpleUUID).

Would you like me to close this request, and open another for just the String#is_binary_data? fix?

@kreynolds
Owner

Yes, that would be excellent.

@kreynolds kreynolds closed this Aug 19, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment