Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to guys interprete "A null value in criteria[n] matches any field"

 
lambertlee Li
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In my search GUI, when user input "Name" field with "A", but leave "Location" blank, I go search based on criteria "Name" starts with "A". Then how about if user neither input "Name" nor "Location",then click search button. Should I return a list of all records to user? Doing this way satisfy the requirement of "A null value in criteria[n] matches any field" ? I personally don't want to go this way as I already provided user a separate button to allow view all the records. I intend to prevent user from going further to search if he/she leave all search fields blank. But just scared by doing this, I wouldn't fulfill the requirement of "A null value in criteria[n] matches any field". How do you guys think?
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kaymen ji:
Hi,

In my search GUI, when user input "Name" field with "A", but leave "Location" blank, I go search based on criteria "Name" starts with "A". Then how about if user neither input "Name" nor "Location",then click search button. Should I return a list of all records to user? Doing this way satisfy the requirement of "A null value in criteria[n] matches any field" ?

Your best option is to follow the criteria as set down for the data class when implementing the find[] method, so null on all fields returns all records. As I think it would be risking automatic failure not to do so.

However...


I personally don't want to go this way as I already provided user a separate button to allow view all the records. I intend to prevent user from going further to search if he/she leave all search fields blank. But just scared by doing this, I wouldn't fulfill the requirement of "A null value in criteria[n] matches any field". How do you guys think?


There is nothing to stop you having another search method in a higher business layer that the GUI interacts with instead of dealing directly with data. This method could be used to filter the results of the find[] method in whatever way you see fit for your search function.
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you do this:



You would get all the hotels that start with "Marriot" irrespective of the values of the rest of the fields.


If you do this:



You would be fetching all the records.
 
lambertlee Li
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

thanks Mark and Edwin. Yes, I have those


In my Database class. So that means as long as I providing those methods in my Database class, I could do something a little bit different on GUI side, is what you mean Mark?
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, now your business class can retrieve all records and do some filtering to exclude those not matching a specific criteria.

For instance, those hotels which are not available, or the hotels that are not booked yet.
 
Mark Smyth
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kaymen ji:
Hi,

thanks Mark and Edwin. Yes, I have those


In my Database class. So that means as long as I providing those methods in my Database class, I could do something a little bit different on GUI side, is what you mean Mark?


Well in my implementation I have a DataClient class with two methods bookRoom(id, recNo) and search(Room searchCriteria, boolean exactMatch, boolean caseSensitive).

The room object is just a wrapper for the record data. In my search method if I want to return all records I send an empty room object to the method. This way it is also very easy to add in addtional search fields in the future.

For example If I want an exact match on a name / location I call data.find() to return all similar records and then discard the one that don't exactly match.

For example if I searched the location "Clare"

And find method returned
"Clare"
"Claregalway"
"Claremorris"

If exact match flag is set to trueI return only "Clare" to the client.
If it is false I return all three to the client.

Hope this helps,
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic