thobbs / phpcassa

PHP client library for Apache Cassandra
thobbs.github.com/phpcassa
MIT License
248 stars 78 forks source link

executing CQL insert randomly works #72

Closed Crim closed 12 years ago

Crim commented 12 years ago

Using the following schema:

CREATE TABLE my_audit (
  v_id varchar, 
  a_id uuid,
  p_id int,
  PRIMARY KEY (v_id, a_id)
);

And executing the following php code:

$conn = new ConnectionPool('pi', array('127.0.0.1:9160'));
$rawCon = $conn->get();
$query = "insert into my_audit (v_id, a_id, p_id) values ('1_2', '14f17cb0-9fbc-11e1-b4af-a95b6f9128a4', 1)"
$rawCon->client->execute_cql_query($query, 2);
$conn->return_connection($rawCon);

About 1/3rd of the time it inserts correctly. The other times i get the following error: "unable to coerce 'p_id' to version 1 UUID"

thobbs commented 12 years ago

What is your schema like?

thobbs commented 12 years ago

Sorry, missed the first half of your comment :)

thobbs commented 12 years ago

I think the issue is that you need to do:

$rawCon->client->set_cql_version("3.0.0")

before you execute your query.

However, I should note that CQL is not technically supported at all through phpcassa yet. As you can see, there's nothing preventing you from trying to make it work, but there are typically some issues. There should be full support for CQL some time soon in the future.

Crim commented 12 years ago

Ah thanks so much! Really appreciate the response! I'll give that a shot.