Commits

tbrugz committed a0d3bfa

queryon: changes in projection (fields)

Comments (0)

Files changed (2)

src/tbrugz/queryon/QueryOn.java

 		//XXX app-specific xtra filters, like auth filters? app should extend QueryOn & implement addXtraConstraints
 		//appXtraConstraints(relation, sql, reqspec, req);
 		
-		//order by
+		// order by
 		sql.applyOrder(reqspec);
 
+		// projection (select columns)
+		sql.applyProjection(reqspec);
+		
+		//XXX: option to add distinct?
+
 		//limit-offset
 		//how to decide strategy? default is LimitOffsetStrategy.RESULTSET_CONTROL
 		//query type (table, view, query), resultsetType? (not avaiable at this point), database type

src/tbrugz/queryon/SQL.java

 			Query q = (Query) relation;
 			SQL sql = new SQL( q.getQuery() , relation);
 			sql.originalBindParameterCount = q.getParameterCount(); 
-			if(reqspec.columns.size()>0) {
-				sql.addProjection(createSQLColumns(reqspec, relation));
-			}
 			return sql;
 		}
 		else if(relation instanceof Table) {
 		return;
 	}
 	
+	public void applyProjection(RequestSpec reqspec) {
+		if(relation instanceof Query && reqspec.columns.size()>0) {
+			addProjection(createSQLColumns(reqspec, relation));
+		}
+	}
+	
 	public static String createSQLColumns(RequestSpec reqspec, Relation table) {
 		String columns = "*";
 		if(reqspec.columns.size()>0) {