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 Nicklas Nordborg, 17 years ago

Owner: changed from Martin Svensson to Nicklas Nordborg
Status: newassigned

comment:2 by Nicklas Nordborg, 17 years ago

Resolution: fixed
Status: assignedclosed

(In [4008]) Fixes #846: Add query parameters to QueryOptions

Note: See TracTickets for help on using tickets.