
var Expr = require ('./expr');
var ListHolder = require ('./list-holder');

/**
 * The equivalent of a SQL function.
 */
module.exports = new Class
({
	Extends: Expr
	,Tag: 'sql-function'
	,Implements: ListHolder
	,Properties:
	{
		/**
		 * The function name.
		 */
		name:
		{
			type: String
			,value: null
		},
		/**
		 * The function schema.
		 */
		schema:
		{
			type: String
			,value: null
		},
		/**
		 * The function parameters.
		 */
		params:
		{
			type: Array
			,set: function (x)
			{
				this.list = x;
			}
			,get: function ()
			{
				return this.list;
			}
		}
	}

	,render: function (params)
	{
		return this.renderPreIdent (this.schema)
			+ this.renderIdent (this.name)
			+ '('
			+ this.renderListWs (this.list, params, ', ')
			+ ')';
	}
});
