Changed query builder to cast parameters to SQL equivalents.