Skip to content

Commit

Permalink
[ci skip] add link to types table
Browse files Browse the repository at this point in the history
  • Loading branch information
Bulat Shakirzyanov committed Oct 29, 2014
1 parent 1d6e6d2 commit 840f25a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ For queries that will be run repeatedly, [you should use Prepared statements](#p

## Parameterized queries

If you're using Cassandra 2.0 or later you no longer have to build CQL strings when you want to insert a value in a query, there's a new feature that lets you bind values with reqular statements:
If you're using Cassandra 2.0 or later you no longer have to build CQL strings when you want to insert a value in a query, there's a new feature that lets you bind values with regular statements:

```ruby
session.execute("UPDATE users SET age = ? WHERE user_name = ?", 41, 'Sam')
```

If you find yourself doing this often, it's better to use prepared statements. As a rule of thumb, if your application is sending a request more than once, a prepared statement is almost always the right choice.

When you use bound values with regular statements the type of the values has to be guessed. Cassandra supports multiple different numeric types, but there's no reliable way of guessing whether or not a Ruby `Fixnum` should be encoded as a `BIGINT` or `INT`, or whether a Ruby `Float` is a `DOUBLE` or `FLOAT`. When there are multiple choices the encoder will pick the larger type (e.g. `BIGINT` over `INT`). For Ruby strings it will always guess `VARCHAR`, never `BLOB`.
When you use bound values with regular statements the type of the values has to be guessed. Cassandra supports multiple different numeric types, but there's no reliable way of guessing whether or not a Ruby `Fixnum` should be encoded as a `BIGINT` or `INT`, or whether a Ruby `Float` is a `DOUBLE` or `FLOAT`. When there are multiple choices the encoder will pick the larger type (e.g. `BIGINT` over `INT`). For Ruby strings it will always guess `VARCHAR`, never `BLOB`. [Check out this types mapping table for additional details](http://datastax.github.io/ruby-driver/features/basics/#ruby-objects-to-from-apache-cassandra-datatypes).

## Executing Statements in Parallel

Expand Down Expand Up @@ -423,4 +423,4 @@ Compression works best for large requests, so if you use batching you should ben

[1]: https://github.com/apache/cassandra/blob/cassandra-2.0/doc/cql3/CQL.textile
[2]: http://www.datastax.com/documentation/cql/3.1/webhelp/index.html
[3]: https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v2.spec
[3]: https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v2.spec

0 comments on commit 840f25a

Please sign in to comment.