lib/newsql.js
function  buildSqlFilter(filter, columns)  {
	if (filter.op === 'and')  {
		var  clones = [];
		filter.filters.forEach(function(f) {
			var  cf = buildSqlFilter(f, columns);
			if (cf)
				clones.push( cf );
		});
		
		var  len = clones.length;
		if (len < 1)
			return null;
		else
			return  len > 1  ?  {op: 'and', filters: clones} : clones[0];
	}
	else  if (filter.op === 'or')  {
		var  clones = [];
		filter.filters.forEach(function(f) {
			var  cf = buildSqlFilter(f, columns);
			if (cf)
				clones.push( cf );
		});

		return  clones.length === filter.filters.length  ?  {op: 'or', filters: clones} : null;
	}

	var  cf = null,
		 colName = filter.name;
	if (columns.indexOf(colName) >= 0)
		cf = filter; //cloneObj( filter );


	return  cf;
}
function  buildSqlFilter(filter, columns)  {
	if (filter.op === 'and')  {
		var  clones = [];
		filter.filters.forEach(function(f) {
			var  cf = buildSqlFilter(f, columns);
			if (cf)
				clones.push( cf );
		});
		
		var  len = clones.length;
		if (len < 1)
			return null;
		else
			return  len > 1  ?  {op: 'and', filters: clones} : clones[0];
	}
	else  if (filter.op === 'or')  {
		var  clones = [];
		filter.filters.forEach(function(f) {
			var  cf = buildSqlFilter(f, columns);
			if (cf)
				clones.push( cf );
		});

		return  clones.length === filter.filters.length  ?  {op: 'or', filters: clones} : null;
	}

	var  cf = null,
		 colName = filter.name;
	if (columns.indexOf(colName) >= 0)
		cf = filter; //cloneObj( filter );


	return  cf;
}
function buildSqlFilter ( filter , columns ) { if ( filter . op === 'and' ) { var clones = [ ] ; filter . filters . forEach ( function ( f ) { var cf = buildSqlFilter ( f , columns ) ; if ( cf ) clones . push ( cf ) ; } ) ; var len = clones . length ; if ( len < 1 ) return null ; else return len > 1 ? { op : 'and' , filters : clones } : clones [ 0 ] ; } else if ( filter . op === 'or' ) { var clones = [ ] ; filter . filters . forEach ( function ( f ) { var cf = buildSqlFilter ( f , columns ) ; if ( cf ) clones . push ( cf ) ; } ) ; return clones . length === filter . filters . length ? { op : 'or' , filters : clones } : null ; } var cf = null , colName = filter . name ; if ( columns . indexOf ( colName ) >= 0 ) cf = filter ; //cloneObj( filter ); return cf ; }
Build a new SQL filter with 'inertia' columns
Build a new SQL filter with inertia columns