use of lucee.runtime.db.SQLItem in project Lucee by lucee.
the class QueryParamConverter method convert.
public static SQL convert(String sql, Array params) throws PageException {
Iterator<Object> it = params.valueIterator();
List<SQLItems<NamedSQLItem>> namedItems = new ArrayList<SQLItems<NamedSQLItem>>();
List<SQLItems<SQLItem>> items = new ArrayList<SQLItems<SQLItem>>();
Object value, paramValue;
while (it.hasNext()) {
value = it.next();
if (Decision.isStruct(value)) {
Struct sct = (Struct) value;
// name (optional)
String name = null;
Object oName = sct.get(KeyConstants._name, null);
if (oName != null)
name = Caster.toString(oName);
// value (required)
paramValue = sct.get(KeyConstants._value);
if (StringUtil.isEmpty(name)) {
items.add(new SQLItems<SQLItem>(new SQLItemImpl(paramValue, Types.VARCHAR), sct));
} else {
namedItems.add(new SQLItems<NamedSQLItem>(new NamedSQLItem(name, paramValue, Types.VARCHAR), sct));
}
} else {
items.add(new SQLItems<SQLItem>(new SQLItemImpl(value)));
}
}
return convert(sql, items, namedItems);
}
Aggregations