Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Problems with decimal type and prepared statements #33

Closed
kalifs opened this issue Aug 5, 2013 · 4 comments
Closed

Problems with decimal type and prepared statements #33

kalifs opened this issue Aug 5, 2013 · 4 comments
Labels

Comments

@kalifs
Copy link

kalifs commented Aug 5, 2013

I tried to use decimal type in Cassandra and it works fine when I do that through cqlsh and I can get back results, but with cql-rb, this happens:

pry(main)> client = Cql::Client.connect(host: 'localhost')
pry(main)> client.use('my_keyspace')
=> nil
pry(main)> client.execute(%^
pry(main)*    CREATE TABLE my_table (
pry(main)*      id uuid,
pry(main)*      random_number decimal,
pry(main)*      PRIMARY KEY (id)
pry(main)*    )
pry(main)* ^)
=> nil
pry(main)> client.execute('INSERT INTO my_table (id, random_number) VALUES (f13940f4-fdd6-11e2-9bb6-bfc6cf90febe, 0.0012095473475870063)')
=> nil
client.execute('SELECT * FROM my_table WHERE id = f13940f4-fdd6-11e2-9bb6-bfc6cf90febe')
Cql::IoError: undefined method `<<' for nil:NilClass
from ~/.rvm/gems/ruby-2.0.0-p195@my_gemset/gems/cql-rb-1.0.3/lib/cql/protocol/decoding.rb:35:in `read_decimal!'

Also I tried to use prepared statement and error again

pry(main)> statement=client.prepare('INSERT INTO my_table (id, random_number) VALUES (f13940f4-fdd6-11e2-9bb6-bfc6cf90febe, ?)')
pry(main)> statement.execute( 0.0012095473475870063)
NoMethodError: undefined method `split' for 0.0012095473475870063:Float
from ~/.rvm/gems/ruby-2.0.0-p195@my_gemset/gems/cql-rb-1.0.3/lib/cql/protocol/encoding.rb:94:in `write_decimal'
@iconara
Copy link
Owner

iconara commented Aug 5, 2013

I'll have a look and see what's broken.

@iconara iconara closed this as completed in 2b63d14 Aug 5, 2013
@iconara
Copy link
Owner

iconara commented Aug 5, 2013

I will backport the fix to the v1.0.x branch and release a v1.0.4 shortly.

iconara added a commit that referenced this issue Aug 5, 2013
When there were only fractions there were negative substring lengths, and negative numbers with only fractions did not work either.

This fixes #33
@iconara
Copy link
Owner

iconara commented Aug 6, 2013

v1.0.4 has been released to Rubygems.

@kalifs
Copy link
Author

kalifs commented Aug 6, 2013

Thanks, that works fine now!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants