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

/**
 * The equivalent of a SQL field.
 *
 * @param {string} taget The name of the owner table
 */
module.exports = new Class
({
	Extends: Expr
	,Tag: 'sql-field'
	,Properties:
	{
		/**
		 * The column name.
		 */
		name:
		{
			type: String
			,value: null
		},
		/**
		 * The source table name or its alias if it has been specified.
		 */
		target:
		{
			type: String
			,value: null
		}
	}

	,render: function ()
	{
		var sql = (this.target) ? '`' + this.target + '`.' : '';	
		return sql + '`' + this.name + '`';
	}
});
