• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

criteriaFind String

 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Hi Ranchers, I have quick couple of questions regarding criteriaFind()
Here is what my criteriaFind does ....

if(emptyString) {

return all rows;
} else {
parseCriteria();

return appropriateRows
}
Here are my questions:
1) Is the above logic fine ? My precise question is : We need to treat the
case of "Empty String" seperately .. is that right ..?
2) a) Should my criteriaFind be generic enough to support this kind of argument to criteriaFind ?


"Carrier='Travel's,Inc',Destination airport='SFO'" ..?
Please, carefully look at the value of the carrier ....

b) Another related question: As we are storing the values for the fields in the database as "SFO", what we are doing
when thw user sends string "Destination airport='SFO'" is, we are essentially, stripping off
it into "SFO" and comparing instead of stripping it into "'SFO'" and comparing... is that right ..?
Please,clear this confusion for me.
Thank You guys,
Regards,
Krishna Varma Adluru
 
HanMing Low
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
For my case,
1) I didn't handle the empty string as I think the requirement says that other than 'Any', only exact match needs to be handled.
So, I thought that there wouldn't be an exact match for an empty string
2) a) I handle the ' within a String. I use a CriteriaParser to parse the Criteria string to handle the Key/Value pair accordingly and return it to the calling method.
b) I think stripping the beginning and ending ' must be the case. Otherwise, there won't be an exact match for 'SFO' in the database.
Hope this helps.
Han Ming
 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HanMing Low,
Thank You very much for the reply. Your answer cleared my 2nd question. But, my 1st question is still valid.
Let me give an example.
If we need to search for "ANY" carrier, "ANY" origin airport, "ANY" destination airport, then there is NO specific query. So, we need to pass
an EMPTY string to criteriaFind method and it needs to give all the records in the table.
Is my understanding correct ?
Thanks in advance.
Regards,
Krishna Varma Adluru
 
Krishna Varma Adluru
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HanMing Low,
Thank You very much for the reply. Your answer cleared my 2nd question. But, my 1st question is still valid.
Let me give an example.
If we need to search for "ANY" carrier, "ANY" origin airport, "ANY" destination airport, then there is NO specific query. So, we need to pass
an EMPTY string to criteriaFind method and it needs to give all the records in the table.
Is my understanding correct ?
Thanks in advance.
Regards,
Krishna Varma Adluru
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Is the above logic fine ? My precise question is : We need to treat the
case of "Empty String" seperately .. is that right ..?
That is absolutely correct. An empty criteria string means all records.
Mark
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont beleive an empty String is the same as ANY. EMPTY String is when the field is expected to be blank. So if Origin="" then the criteria means find me those flights only whose Origin is a blank. ANY is a wild card like *. Only exact matches were specified.My 2cents here.
 
HanMing Low
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Krishna,
Yup, I think I miss your point for the second part.
For my case, I did handle ' within the ' '.
But I guess so long you document your limitation in your documentation if you decide not to support it, then you should be fine.
As for the empty string, my interpretation is the same as Kalichar where empty does not means Any. The calling method has to specifically specify 'Any' to have the wildcard.
Again, I think if you document it, then you're fine.
Hope that helps.

Han Ming
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What record in your db.db file is blank? None, so don't go overboard
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic