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

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

	,expr: []

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

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