1. tbrugz
  2. queryon

Commits

tbrugz  committed e2bd835

limit/offset updated

  • Participants
  • Parent commits 338eb98
  • Branches default

Comments (0)

Files changed (3)

File src/tbrugz/queryon/DBUtil.java

View file
 	
 	//XXX: getSQLTypeForColumnType(String colType): add dbid as parameter? 
 	public static int getSQLTypeForColumnType(String colType) {
-		if(colType==null) {	return Types.VARCHAR; }
+		if(colType==null) { return Types.VARCHAR; }
 		
 		if(colType.equalsIgnoreCase("BINARY_INTEGER")) {
 			return Types.INTEGER;

File src/tbrugz/queryon/QueryOn.java

View file
 	}
 	
 	void dumpResultSet(ResultSet rs, RequestSpec reqspec, String queryName, List<String> uniqueColumns, HttpServletResponse resp) throws SQLException, IOException {
+		int resultSetType = rs.getType();
 		if(reqspec.offset>0) {
-			rs.absolute(reqspec.offset);
+			if(resultSetType!=ResultSet.TYPE_FORWARD_ONLY) {
+				rs.absolute(reqspec.offset);
+			}
+			else {
+				log.warn("cant offset: ResultSet type is FORWARD_ONLY");
+			}
 		}
 		int count = 0;
 		DumpSyntax ds = reqspec.outputSyntax;
 		while(rs.next()) {
 			ds.dumpRow(rs, count, resp.getWriter());
 			count++;
-			if(reqspec.length>0 && count>reqspec.length) break;
+			if(reqspec.limit>0 && count>=reqspec.limit) break;
 		}
 		ds.dumpFooter(resp.getWriter());
 	}

File src/tbrugz/queryon/RequestSpec.java

View file
 	final String httpMethod;
 	final String object;
 	final String action;
-	int offset, length;
+	final int offset, limit;
 	List<String> columns = new ArrayList<String>();
 	List<String> params = new ArrayList<String>();
 	String outputTypeStr = QueryOn.DEFAULT_OUTPUT_SYNTAX;
 		//---------------------
 		
 		String offsetStr = req.getParameter("offset");
-		if(offsetStr!=null) offset = Integer.parseInt(offsetStr);
+		if(offsetStr!=null) { offset = Integer.parseInt(offsetStr); }
+		else { offset = 0; }
 
-		String lengthStr = req.getParameter("length");
-		if(lengthStr!=null) length = Integer.parseInt(lengthStr);
+		String lengthStr = req.getParameter("limit");
+		if(lengthStr!=null) { limit = Integer.parseInt(lengthStr); }
+		else { limit = -1; }
 		
 		for(int i=1;;i++) {
 			String value = req.getParameter("c"+i);