CQL generated from linq seems to be incorrect

Showing 1-3 of 3 messages
CQL generated from linq seems to be incorrect Ryan Caskey 8/2/12 1:11 PM
Hello Everyone,
  I have a columnfamily that I've generated programmatically (along with secondary indexes), and now want to query it at run time with an arbitrary number of parameters.  I've done this by running the following code:

var queryParams = new Dictionary<string, string>();

//populate queryParams
.
.
.

IQueryable<ICqlRow> query = family;

queryParams
.Keys.ToList().ForEach(paramKey => query = query.Where(q => q[paramKey] == queryParams[paramKey]));

I'm having two problems with this.  The first is I get a "Call is not supported" exception when I try to evaluate the query.  I came across another issue as I begin to break it down to smaller examples.

I tried something simple: 
query = query.Where(t => t["Param1"] == "Value1");

That worked fine.  The CQL it generated was
SELECT * 
FROM SampleColumnFamily 
WHERE Param1 = 'Value1'

I tried beefing up my simple example:
query = query.Where(t => t["Param1"] == "Value1").Where(t => t["Param2"] == "Value2");

This produced
SELECT * 
FROM  SampleColumnFamily   
WHERE (Param1 = 'Value1' AND Param2 = 'Value2')

It looks good, however this is where I ran into my second issue.  I get this error: "line 3:6 no viable alternative at input '('".  It turns out it didn't like the () around the where clause.  If I remove them, it seems to work fine.  Perhaps this is an issue with the LINQ provider in FluentCassandra?

However, that didn't answer my "Call is not supported" exception.  After I did some more digging I came up with another scenario.

//This works
query.Where(t => t["Param1"] == "Value1");

//This doesn't
string p1 = "Param1";
query.Where(t => t[p1] == "Value1");

Instead of seeing the CQL when I mouse over query in the IDE, all I see is {FluentCassandra.Linq.CqlQuery}.  If I try to execute that query, I get the "Call is not supported" exception.

Any ideas (other than hand writing my CQL)?

Re: [FluentCassandra:80] CQL generated from linq seems to be incorrect Nick Berardi 8/2/12 1:52 PM
I think you have stumbled on to something I didn't consider.  Would you mind sending me a pull request in this LINQ Test, with the issues that you have raised.  

This one is for dynamic queries with no object

This one is for queries with objects

That way I can have them documented and in front of me.

Nick


--
You received this message because you are subscribed to the Google Groups "FluentCassandra" group.
To post to this group, send email to fluentc...@googlegroups.com.
To unsubscribe from this group, send email to fluentcassand...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/fluentcassandra/-/QUNmc48ZfLUJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: [FluentCassandra:80] CQL generated from linq seems to be incorrect Ryan Caskey 8/2/12 2:41 PM
Pull request sent.


On Thursday, August 2, 2012 4:52:49 PM UTC-4, Nick Berardi wrote:
I think you have stumbled on to something I didn't consider.  Would you mind sending me a pull request in this LINQ Test, with the issues that you have raised.  

This one is for dynamic queries with no object

This one is for queries with objects

That way I can have them documented and in front of me.

Nick