
var Object = require ('./object');
var Expr = require ('./expr');

/**
 * The equivalent of a SQL statement.
 */
module.exports = new Class
({
	Extends: Object
	,Properties:
	{
		where:
		{
			type: Expr
			,value: null
		}
	}

	,target: []

	,addTarget: function (target)
	{
		this.target.push (target);
	}

	,renderTarget: function (batch)
	{
		var sql;
		var len = this.target.length;
		
		if (len > 0)
		{
			sql = ' ';
		
			for (var n = 0; n < len; n++)
			{
				if (n > 0) sql += ', ';
				sql += this.target[n].render (batch);
			}
		}
		else
			sql += 'DUAL';
		
		return sql;
	}		
});
