
var Stmt = require('./stmt');
var Field = require('./field');

/**
 * The equivalent of a SQL select.
 */
module.exports = new Class({
	Extends: Stmt

	,expr: []

	,addField(fieldName) {
		this.expr.push(new Field({name: fieldName}));
	}

	,render(params) {
		return 'SELECT '
			+ this.renderListWs(this.expr, params, ', ')
			+ ' FROM'
			+ this.renderTarget(params)
			+ this.renderIfSet(this.where, 'WHERE', params)
			+ this.renderLimit(params);
	}
});
