<!--- version 2.01---><!---15:25 31.01.2019--->
<!--- version 2.02---><!---2025-08-04 15:19:34 postgre specific ilike instead of like--->
<!--- build query filter string --->
<!--- пустые и некорректные значения параметров вызвыают пропуск параметра --->
<cfparam name="ATTRIBUTES.filter" type="struct"/>

<cfloop collection=#ATTRIBUTES.filter# item="item">
	<cfsilent>

		<cfset fltr=structFind(ATTRIBUTES.filter,item)>
		<cfparam name="fltr.val" default=""/>
		<cfparam name="fltr.prefix" default=""/>
		<cfparam name="fltr.suffix" default=""/>
		<cfparam name="fltr.list" default="No"/>			
	</cfsilent>	<!---	
	
---> AND <cfif structKeyExists(fltr,"expression") AND len(fltr.expression)><!---
			---><cfset len=listLen(#fltr.expression#,"?")><!---
			---><cfloop from=1 to=#len# index="i"><!---
				---><cfoutput>#listGetAt(fltr.expression,i,"?")#</cfoutput><!---
				---><cfif i LT #len#><cfqueryparam cfsqltype="#getCfSqLType(fltr.ftype)#" list="#fltr.list#" value="#fltr.prefix##fltr.val##fltr.suffix#"/></cfif><!---
			---></cfloop><!---
		---><cfelse><!---
		---><cfoutput>#fltr.field#</cfoutput><cfswitch expression=#fltr.compare#><cfcase value="EQ"> = </cfcase><cfcase value="NE,NEQ"> <> </cfcase><cfcase value="LE"> <= </cfcase><cfcase value="LT"> < </cfcase><cfcase value="GE"> >= </cfcase><cfcase value="GT"> > </cfcase><cfcase value="LIKE"> ILIKE </cfcase><cfcase value="NOTLIKE"> NOT ILIKE </cfcase><cfcase value="LIKE%"> ILIKE <cfqueryparam cfsqltype=#getCfSqLType(fltr.ftype)# value="%#fltr.val#%"/><cfcontinue/></cfcase><cfcase value="NOTLIKE%"> NOT ILIKE <cfqueryparam cfsqltype=#getCfSqLType(fltr.ftype)# value="%#fltr.val#%"/><cfcontinue/></cfcase><cfcase value="IN"> IN (<cfqueryparam cfsqltype=#getCfSqLType(fltr.ftype)# list="#fltr.list#" value="#fltr.val#"/>)<cfcontinue/></cfcase><cfdefaultcase> = <cfoutput> #fltr.field#</cfoutput><cfcontinue/><!---***криво---></cfdefaultcase></cfswitch><cfqueryparam cfsqltype=#getCfSqLType(fltr.ftype)# value="#fltr.val#"/><cfcontinue/>
		</cfif>
</cfloop>


<cfexit method="exittag"/>

<cffunction name="getCfSqlType" output="No">
	<cfargument name="fieldType" default=""/>
	<cfswitch expression=#ARGUMENTS.fieldType#>
		<cfcase value="numeric">
			<cfreturn "CF_SQL_NUMERIC"/>
		</cfcase>		
		<cfcase value="date,time,datetime">
			<cfreturn "CF_SQL_TIMESTAMP"/>
		</cfcase>		
		<cfcase value="guid">
			<cfreturn "CF_SQL_OTHER"/>
		</cfcase>		
		<cfcase value="string">
			<cfreturn "CF_SQL_VARCHAR"/>
		</cfcase>
		<cfdefaultcase>
			<cfreturn "CF_SQL_VARCHAR"/>
		</cfdefaultcase>
	</cfswitch>
</cffunction>
