Opened 17 years ago
Closed 17 years ago
#846 closed enhancement (fixed)
Add query parameters to QueryOptions
Reported by: | Nicklas Nordborg | Owned by: | Nicklas Nordborg |
---|---|---|---|
Priority: | major | Milestone: | BASE 2.5 |
Component: | webservices | Version: | |
Keywords: | Cc: |
Description
When doing a web services request with a restriction you currently have to hardcode this. For example:
String theName = "The name"; QueryOptions options = new QueryOptions(); options.setRestriction("name = '" + theName + "'");
This may do well for prototype work, but if the name we are looking for comes from user input we must not trust it and it may contain 'bad' characters. The best way is to pass the name as a parameter:
String theName = "The name"; QueryOptions options = new QueryOptions(); options.setRestriction("name = :name); options.addParameter(new QueryParameter("name", "STRING", theName));
So, we need to add a QueryParameter object to the API. The first parameter is the name of the parameter as it appears in the restriction. The second parameter is the name of the type from the net.sf.basedb.core.Type enumeration. The last parameter is the actual value.
Change History (2)
comment:1 by , 17 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
(In [4008]) Fixes #846: Add query parameters to QueryOptions