TQL and params lexicon update
I've made another change to the tql.cfm and parameter.cfm lexicon for Transfer and Fusebox.
This now takes into account the dataType argument and it allows for the 'list' argument to be set - which is helpful if you're doing a select IN statement.
I've changed in tql.cfm line 32 to:
and in parameter.cfm i've inserted at line 29:
fb_.verbInfo.parent.dataType = fb_.verbInfo.attributes.dataType;
} else {
fb_.verbInfo.parent.dataType = 'any';
}
if (structKeyExists(fb_.verbInfo.attributes,"isList")) {
fb_.verbInfo.parent.isList = fb_.verbInfo.attributes.isList;
} else {
fb_.verbInfo.parent.isList = 0;
}
A usage case would be:
<tr:tql tql=" from applicant.applicant as applicant where applicant.isJudged = :isJudged AND applicant.category IN (:category) order by applicant.applicant.date_applied DESC" queryName="qUnjudged">
<tr:parameter name="isJudged" value="0" dataType="int" />
<tr:parameter name="category" value="categories" dataType="string" isList="true"/>
</tr:tql>
Here is the full parameter.cfm lexicon:
// usage inside other verbs: // <transfer:parameter
// name="paramName"
// value="someVal"
// dataType="date"
// isList="1" />
if (fb_.verbInfo.executionMode is "start") {
// validate attributes // <parameter> must have a parent verb this lexicon: if (structKeyExists(fb_.verbInfo,"parent") and
fb_.verbInfo.parent.lexicon is fb_.verbInfo.lexicon and
listFind("delete,read,save,tql",fb_.verbInfo.parent.lexiconVerb) neq 0) {
// name - string - required if (not structKeyExists(fb_.verbInfo.attributes,"name")) {
fb_throw("fusebox.badGrammar.requiredAttributeMissing",
"Required attribute is missing",
"The attribute 'name' is required, for a 'parameter' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
}
// value - string - required if (not structKeyExists(fb_.verbInfo.attributes,"value")) {
fb_throw("fusebox.badGrammar.requiredAttributeMissing",
"Required attribute is missing",
"The attribute 'value' is required, for a 'parameter' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
}
// add this parameter to the parent data: fb_.verbInfo.parent.parameters[fb_.verbInfo.attributes.name] = fb_.verbInfo.attributes.value;
if (structKeyExists(fb_.verbInfo.attributes,"dataType")) {
fb_.verbInfo.parent.dataType = fb_.verbInfo.attributes.dataType;
} else {
fb_.verbInfo.parent.dataType = 'any';
}
if (structKeyExists(fb_.verbInfo.attributes,"isList")) {
fb_.verbInfo.parent.isList = fb_.verbInfo.attributes.isList;
} else {
fb_.verbInfo.parent.isList = 0;
}
} else {
fb_throw("fusebox.badGrammar.parameterInvalidParent",
"Verb 'parameter' has invalid parent verb",
"Found 'parameter' verb with no valid parent verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
}
}
</cfscript>
and the TQL lexicon:
// author: Nick Tong - http://succor.co.uk | http://talkwebsolutions.co.uk // usage: // <transfer:tql
// tql=" from post.Post as Post join system.Category join user.User order by Post.dateTime desc "
// queryName="myQueryName">
// <transfer:parameter name="id" value="#attributes.id#" />
// </transfer:tql> if (fb_.verbInfo.executionMode is "start") {
// validate attributes // object - string if (not structKeyExists(fb_.verbInfo.attributes,"tql")) {
fb_throw("fusebox.badGrammar.requiredAttributeMissing",
"Required attribute is missing",
"The attribute 'tql' is required, for a 'tql' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
}
// queryName - string if (not structKeyExists(fb_.verbInfo.attributes,"queryName")) {
fb_throw("fusebox.badGrammar.requiredAttributeMissing",
"Required attribute is missing",
"The attribute 'queryName' is required, for a 'tql' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
}
// generate code: fb_appendLine('<cfset #fb_.verbInfo.attributes.queryName# = ' &
'myFusebox.getApplication().getApplicationData().transferFactory.getTransfer().createQuery("#fb_.verbInfo.attributes.tql#") />');
// prepare for any parameters: fb_.verbInfo.parameters = structNew();
} else {
for (fb_.p in fb_.verbInfo.parameters) {
fb_appendLine('<cfset #fb_.verbInfo.attributes.queryName#.setParam("#fb_.p#",#fb_.verbInfo.parameters[fb_.p]#,"#fb_.verbInfo.dataType#",#fb_.verbInfo.isList#) />');
}
fb_appendLine('<cfset #fb_.verbInfo.attributes.queryName# = ' &
'myFusebox.getApplication().getApplicationData().transferFactory.getTransfer().listByQuery(#fb_.verbInfo.attributes.queryName#) />');
fb_appendLine('<cfset myFusebox.trace("Transfer","Created TQL Query") />');
}
</cfscript>
You can override these in the transfer lexicon folder*.
* back up first





There are no comments for this entry.
[Add Comment]