
| Key: |
VER-17
|
| Type: |
Bug
|
| Status: |
Open
|
| Priority: |
Minor
|
| Assignee: |
Unassigned
|
| Reporter: |
Andrew Mercer
|
| Votes: |
0
|
| Watchers: |
0
|
|
|
FarCry Verity
Created: 23/Nov/07 04:14 PM
Updated: 24/Jan/08 02:29 PM
|
|
| Component/s: |
None
|
| Affects Version/s: |
None
|
| Fix Version/s: |
None
|
|
|
<!--- bowden - overriden from dbgateway to handle longtext as clob. --->
<cffunction name="generateSQLNameValueArray" access="private" output="false" returntype="array" hint="Generates an array of structs. Each struct contains three keys column, cfsqltype and value. The column matches the database column name and the value is the SQL fragment that should be passed to the database for the column. The cfsqltype indicates the value for the type attribute of the cfqueryparam tag.">
<cfargument name="tableDef" type="struct" required="true" />
<cfargument name="stProperties" type="struct" required="true" />
<cfset var field = "" />
<cfset var SQLArray = arrayNew(1) />
<cfset var propertyValue = "" />
<cfset var stField = structNew() />
<cfloop collection="#tableDef#" item="field">
<cfif StructKeyExists(arguments.stProperties, field)
AND field NEQ "ObjectID"
AND tableDef[field].type neq "array">
<cfset stField = structNew() />
<cfset stField.column = field />
<cfset propertyValue = arguments.stProperties[field]>
<!--- determine sql treatment --->
<cfswitch expression="#tableDef[field].type#">
<cfcase value="date">
<cfif IsDate(propertyValue)>
<cfset stField.cfsqltype = "CF_SQL_TIMESTAMP" />
<cfset stField.value = propertyValue />
<cfelseif tableDef[field].nullable>
<cfset stField.value = "NULL" />
<cfelse>
<!--- AJM: taken from DBGateWay.cfc
<cfabort showerror="Error: #propertyName# must be a date (#propertyValue#).">
--->
<cfabort showerror="Error: #field# must be a date (#propertyValue#).">
</cfif>
</cfcase>
<cfcase value="numeric">
<cfif IsNumeric(propertyValue)>
<cfset stField.value = propertyValue />
<cfelse>
<cfset stField.value = 0>
</cfif>
<cfset stField.cfsqltype = "CF_SQL_FLOAT" />
</cfcase>
<cfcase value="boolean">
<cfset propertyValue = YesNoFormat(propertyValue)>
<cfif propertyValue eq "Yes">
<cfset propertyValue = 1>
<cfelseif propertyValue eq "No">
<cfset propertyValue = 0>
</cfif>
<cfset stField.value = propertyValue />
<cfset stField.cfsqltype="CF_SQL_INTEGER" />
</cfcase>
<cfcase value="longchar">
<cfset stField.value= propertyValue />
<cfset stField.cfsqltype="CF_SQL_CLOB" />
</cfcase>
<cfdefaultcase>
<!--- string data --->
<cfset stField.value= propertyValue />
<cfset stField.cfsqltype="CF_SQL_VARCHAR" />
</cfdefaultcase>
</cfswitch>
<cfset arrayAppend(sqlArray,stField) />
</cfif>
</cfloop>
<cfreturn sqlArray />
</cffunction>
<!--- end - bowden --->
|
|
Description
|
<!--- bowden - overriden from dbgateway to handle longtext as clob. --->
<cffunction name="generateSQLNameValueArray" access="private" output="false" returntype="array" hint="Generates an array of structs. Each struct contains three keys column, cfsqltype and value. The column matches the database column name and the value is the SQL fragment that should be passed to the database for the column. The cfsqltype indicates the value for the type attribute of the cfqueryparam tag.">
<cfargument name="tableDef" type="struct" required="true" />
<cfargument name="stProperties" type="struct" required="true" />
<cfset var field = "" />
<cfset var SQLArray = arrayNew(1) />
<cfset var propertyValue = "" />
<cfset var stField = structNew() />
<cfloop collection="#tableDef#" item="field">
<cfif StructKeyExists(arguments.stProperties, field)
AND field NEQ "ObjectID"
AND tableDef[field].type neq "array">
<cfset stField = structNew() />
<cfset stField.column = field />
<cfset propertyValue = arguments.stProperties[field]>
<!--- determine sql treatment --->
<cfswitch expression="#tableDef[field].type#">
<cfcase value="date">
<cfif IsDate(propertyValue)>
<cfset stField.cfsqltype = "CF_SQL_TIMESTAMP" />
<cfset stField.value = propertyValue />
<cfelseif tableDef[field].nullable>
<cfset stField.value = "NULL" />
<cfelse>
<!--- AJM: taken from DBGateWay.cfc
<cfabort showerror="Error: #propertyName# must be a date (#propertyValue#).">
--->
<cfabort showerror="Error: #field# must be a date (#propertyValue#).">
</cfif>
</cfcase>
<cfcase value="numeric">
<cfif IsNumeric(propertyValue)>
<cfset stField.value = propertyValue />
<cfelse>
<cfset stField.value = 0>
</cfif>
<cfset stField.cfsqltype = "CF_SQL_FLOAT" />
</cfcase>
<cfcase value="boolean">
<cfset propertyValue = YesNoFormat(propertyValue)>
<cfif propertyValue eq "Yes">
<cfset propertyValue = 1>
<cfelseif propertyValue eq "No">
<cfset propertyValue = 0>
</cfif>
<cfset stField.value = propertyValue />
<cfset stField.cfsqltype="CF_SQL_INTEGER" />
</cfcase>
<cfcase value="longchar">
<cfset stField.value= propertyValue />
<cfset stField.cfsqltype="CF_SQL_CLOB" />
</cfcase>
<cfdefaultcase>
<!--- string data --->
<cfset stField.value= propertyValue />
<cfset stField.cfsqltype="CF_SQL_VARCHAR" />
</cfdefaultcase>
</cfswitch>
<cfset arrayAppend(sqlArray,stField) />
</cfif>
</cfloop>
<cfreturn sqlArray />
</cffunction>
<!--- end - bowden ---> |
Show » |
| There are no comments yet on this issue.
|
|