Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
fixed issue #98
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Berardi committed Jan 5, 2013
1 parent 55686d5 commit b7aba46
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/Connections/CqlVersion.cs
Expand Up @@ -5,7 +5,7 @@ namespace FluentCassandra.Connections
{
public static class CqlVersion
{
public const string Cql = "0.8.0";
public const string Cql = "2.0.0";
public const string Cql3 = "3.0.0";
public const string Edge = Cql3;
public const string ConnectionDefault = null;
Expand Down
29 changes: 13 additions & 16 deletions src/Operations/ExecuteCqlNonQuery.cs
Expand Up @@ -23,22 +23,19 @@ public override Void Execute()
if (CqlVersion == FluentCassandra.Connections.CqlVersion.ConnectionDefault)
CqlVersion = Session.ConnectionBuilder.CqlVersion;

switch(CqlVersion) {
case FluentCassandra.Connections.CqlVersion.Cql:
Session.GetClient().execute_cql_query(
query,
isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE);
break;

case FluentCassandra.Connections.CqlVersion.Cql3:
Session.GetClient().execute_cql3_query(
query,
isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE,
Session.WriteConsistency);
break;

default:
throw new FluentCassandraException(CqlVersion + " is not a valid CQL version.");
var client = Session.GetClient();

if (CqlVersion == FluentCassandra.Connections.CqlVersion.Cql || client.describe_version() < RpcApiVersion.Cassandra120) {
client.execute_cql_query(
query,
isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE);
} else if (CqlVersion == FluentCassandra.Connections.CqlVersion.Cql3) {
client.execute_cql3_query(
query,
isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE,
Session.ReadConsistency);
} else {
throw new FluentCassandraException(CqlVersion + " is not a valid CQL version.");
}

return new Void();
Expand Down
28 changes: 12 additions & 16 deletions src/Operations/ExecuteCqlQuery.cs
Expand Up @@ -43,24 +43,20 @@ public override IEnumerable<ICqlRow> Execute()
if (CqlVersion == FluentCassandra.Connections.CqlVersion.ConnectionDefault)
CqlVersion = Session.ConnectionBuilder.CqlVersion;

var client = Session.GetClient();
var result = (CqlResult)null;

switch (CqlVersion) {
case FluentCassandra.Connections.CqlVersion.Cql:
result = Session.GetClient().execute_cql_query(
query,
isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE);
break;

case FluentCassandra.Connections.CqlVersion.Cql3:
result = Session.GetClient().execute_cql3_query(
query,
isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE,
Session.ReadConsistency);
break;

default:
throw new FluentCassandraException(CqlVersion + " is not a valid CQL version.");
if (CqlVersion == FluentCassandra.Connections.CqlVersion.Cql || client.describe_version() < RpcApiVersion.Cassandra120) {
result = client.execute_cql_query(
query,
isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE);
} else if (CqlVersion == FluentCassandra.Connections.CqlVersion.Cql3) {
result = client.execute_cql3_query(
query,
isCqlQueryCompressed ? Apache.Cassandra.Compression.GZIP : Apache.Cassandra.Compression.NONE,
Session.ReadConsistency);
} else {
throw new FluentCassandraException(CqlVersion + " is not a valid CQL version.");
}

return GetRows(result);
Expand Down

0 comments on commit b7aba46

Please sign in to comment.