tags:

views:

65

answers:

2

I'm playing with the SubSonic RESTHandler for the first time and it's awesome... There is one quirk tho, that I'm curious about.

RESTHandler.cs (line 319):

//if this column is a string, by default do a fuzzy search
if(comp == Comparison.Like || column.IsString)
{
    comp = Comparison.Like;
    paramValue = String.Concat("%", paramValue, "%");
}

This little blurp of code forces all searches on string columns to wildcard searches by default. This seems counter intutive, since you've provided a nice set of comparisons we can add to a parameter (_is, _notequal, etc...). Is there a reason this was done? The EvalComparison uses "Comparison.Equals" as it's default, so unless a like is explicitly needed the " || column.IsString" looks like it should be removed since it breaks the ability to use different types of comparisons.

This was driving me crazy, since you can't do a "WHERE Field = X" without modifiying code...

Just curious if this is more of a feature than a bug...

Thanks!

Zach

A: 

It does indeed look like a feature. It's based on the idea that, if I am searching for a string in a column without the wildcards, I must match the string exactly or I get no hits. I suspect that this was done to make programming search textboxes easier.

Robert Harvey
+1  A: 

It's because this is a LIKE operation which for a DB usually allows string operations. The feeling at the time was that if you wanted equals you could just use that.

It's been a while since I've touched this code - if you'd be kind enough to open a bug I'll take a look at it.

Rob Conery
thanks, opening now... this is a great hidden gem for doing ajax with a SubSonic DL. Definitely saved me a few hours!
Zachary