Changeset 3

Show
Ignore:
Timestamp:
10/7/2005 11:07:00 PM (3 years ago)
Author:
dhughes
Message:
 
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • reactor/core/abstractObjectFactory.cfc

    r2 r3  
    258258                <cfset var generate = false /> 
    259259                <cfset var structure = 0 /> 
     260                <cfset var baseStructure = 0 /> 
    260261                <cfset var xslBase = 0 /> 
    261262                <cfset var xslCustom = 0 /> 
     
    285286                        <cfset structure = getTableStructure(arguments.name) /> 
    286287                         
    287                         <!--- insure that the base object exists ---> 
    288                         <cfif structure.table.XmlAttributes.baseTable IS NOT arguments.name> 
    289                                 <!--- we need to insure that an object exists ---> 
    290                                 <!--- TODO: right now, this creates and instantiates the object.  in the future I'd like it to only generate the object and only if it doesn't exist ---> 
    291                                 <cfset createGateway(structure.table.XmlAttributes.baseTable) /> 
    292                         </cfif> 
    293                  
    294288                        <!--- read the Gateway xsl ---> 
    295289                        <cffile action="read" file="#expandPath("/reactor/xsl/#getDbType()#/gateway.base.xsl")#" variable="xslBase" /> 
  • reactor/core/mssql/objectFactory.cfc

    r1 r3  
    11<cfcomponent hint="I am a MSSQL Table Factory.  I am load tables from MSSQL." extends="reactor.core.abstractObjectFactory"> 
    22         
    3         <cffunction name="getTableDefinition" access="private" hint="I return the definition for a table." output="false" returntype="struct"> 
    4                 <cfargument name="name" hint="I am the name of the table to get the definition for." required="yes" type="string" /> 
    5                 <cfset var TimedCache = getTimedCache() /> 
    6                 <cfset var q = StructNew() /> 
    7                 <cfset var fkName = "" /> 
    8                  
    9                 <cfif TimedCache.exists("def_" & arguments.name)> 
    10                         <cfset q = TimedCache.getValue("def_" & arguments.name) /> 
    11                 <cfelse> 
    12                         <!--- use db-native techniques to inspect the database ---> 
    13                         <cfstoredproc datasource="#getDsn()#" procedure="sp_tables"> 
    14                                 <cfprocparam cfsqltype="cf_sql_varchar" scale="384" value="#arguments.name#" /> 
    15                                 <cfprocresult name="q.table" resultset="1" /> 
    16                         </cfstoredproc> 
    17                          
    18                         <!--- before we go any further, check to make sure the name is a real table ---> 
    19                         <cfif NOT q.table.recordCount> 
    20                                 <cfthrow type="reactor.InvalidTableName" 
    21                                 message="Invalid Name Argument" 
    22                                 detail="The name argument must be a valid table or view name which exists in the database." /> 
    23                         </cfif> 
    24                          
    25                         <cfstoredproc datasource="#getDsn()#" procedure="sp_pkeys"> 
    26                                 <cfprocparam cfsqltype="cf_sql_varchar" scale="384" value="#arguments.name#" /> 
    27                                 <cfprocresult name="q.primaryKey" resultset="1" /> 
    28                         </cfstoredproc> 
    29                          
    30                         <cfstoredproc datasource="#getDsn()#" procedure="sp_columns"> 
    31                                 <cfprocparam cfsqltype="cf_sql_varchar" scale="384" value="#arguments.name#" /> 
    32                                 <cfprocresult name="q.columns" resultset="1" /> 
    33                         </cfstoredproc> 
    34                          
    35                         <!--- find out which tables are referred to by this table ---> 
    36                         <cfquery name="q.foreignKeys" datasource="#getDsn()#"> 
     3        <cffunction name="getReferencingKeys" access="public" hint="I return a query of external table's keys referencing this table." output="false" returntype="query"> 
     4                <cfargument name="name" hint="I am the name of the table inspect." required="yes" type="string" /> 
     5                <cfset var TimedCache = getTimedCache() /> 
     6                <cfset var qReferencingKey = 0 /> 
     7                 
     8                <cfif TimedCache.exists("referencingKey_" & arguments.name)> 
     9                        <cfset qReferencingKey = TimedCache.getValue("referencingKey_" & arguments.name) /> 
     10                <cfelse> 
     11                        <cfquery name="qReferencingKey" datasource="#getDsn()#"> 
     12                                SELECT so.name as fkName,  
     13                                        forTab.name as foreignTableName,  
     14                                        thsTab.name as thisTableName, 
     15                                        forCol.name as foreignColumnName, 
     16                                        thsCol.name as thisColumnName,   
     17                                        thsTab.name + '.' + thsCol.name + '->' + forTab.name + '.' + forCol.name as asString 
     18                                FROM SysForeignKeys as sfk JOIN SysObjects as so 
     19                                        ON sfk.constid = so.id 
     20                                JOIN SysObjects as forTab 
     21                                        ON sfk.rkeyid = forTab.id 
     22                                JOIN SysObjects as thsTab  
     23                                        ON sfk.fkeyid = thsTab.id 
     24                                JOIN SysColumns as forCol 
     25                                        ON sfk.rkeyid = forCol.id AND sfk.rkey = forCol.colid 
     26                                JOIN SysColumns as thsCol 
     27                                        ON sfk.fkeyid = thsCol.id AND sfk.fkey = thsCol.colid 
     28                                WHERE forTab.name = <cfqueryparam cfsqltype="cf_sql_varchar" scale="128" value="#arguments.name#" /> 
     29                                ORDER BY sfk.constid 
     30                        </cfquery> 
     31                         
     32                        <!--- cache the results ---> 
     33                        <cfset TimedCache.setValue("referencingKey_" & arguments.name, qReferencingKey) /> 
     34                </cfif>          
     35                 
     36                <!--- return the data ---> 
     37                <cfreturn qReferencingKey /> 
     38        </cffunction> 
     39         
     40        <cffunction name="getForeignKeys" access="public" hint="I return a query of foreign key information on the table." output="false" returntype="query"> 
     41                <cfargument name="name" hint="I am the name of the table inspect." required="yes" type="string" /> 
     42                <cfset var TimedCache = getTimedCache() /> 
     43                <cfset var qForeignKey = 0 /> 
     44                 
     45                <cfif TimedCache.exists("foreignKey_" & arguments.name)> 
     46                        <cfset qForeignKey = TimedCache.getValue("foreignKey_" & arguments.name) /> 
     47                <cfelse> 
     48                        <cfquery name="qForeignKey" datasource="#getDsn()#"> 
    3749                                SELECT so.name as fkName,  
    3850                                        forTab.name as foreignTableName,  
     
    5567                        </cfquery> 
    5668                         
    57                         <cfquery name="q.referencingKeys" datasource="#getDsn()#"> 
    58                                 SELECT so.name as fkName,  
    59                                         forTab.name as foreignTableName,  
    60                                         thsTab.name as thisTableName, 
    61                                         forCol.name as foreignColumnName, 
    62                                         thsCol.name as thisColumnName,   
    63                                         thsTab.name + '.' + thsCol.name + '->' + forTab.name + '.' + forCol.name as asString 
    64                                 FROM SysForeignKeys as sfk JOIN SysObjects as so 
    65                                         ON sfk.constid = so.id 
    66                                 JOIN SysObjects as forTab 
    67                                         ON sfk.rkeyid = forTab.id 
    68                                 JOIN SysObjects as thsTab  
    69                                         ON sfk.fkeyid = thsTab.id 
    70                                 JOIN SysColumns as forCol 
    71                                         ON sfk.rkeyid = forCol.id AND sfk.rkey = forCol.colid 
    72                                 JOIN SysColumns as thsCol 
    73                                         ON sfk.fkeyid = thsCol.id AND sfk.fkey = thsCol.colid 
    74                                 WHERE forTab.name = <cfqueryparam cfsqltype="cf_sql_varchar" scale="128" value="#arguments.name#" /> 
    75                                 ORDER BY sfk.constid 
    76                         </cfquery> 
    77                          
    78                         <!--- cache the results ---> 
    79                         <cfset TimedCache.setValue("def_" & arguments.name, q) /> 
    80                 </cfif>          
    81                  
    82                 <!--- return the data ---> 
    83                 <cfreturn q /> 
     69                        <!--- cache the results ---> 
     70                        <cfset TimedCache.setValue("foreignKey_" & arguments.name, qForeignKey) /> 
     71                </cfif>          
     72                 
     73                <!--- return the data ---> 
     74                <cfreturn qForeignKey /> 
     75        </cffunction> 
     76         
     77        <cffunction name="getPrimaryKeyColumnList" access="public" hint="I return a list of columns in the primary on the table." output="false" returntype="string"> 
     78                <cfargument name="name" hint="I am the name of the table inspect." required="yes" type="string" /> 
     79                <cfset var TimedCache = getTimedCache() /> 
     80                <cfset var qPrimaryKey = 0 /> 
     81                <cfset var columnList = "" /> 
     82                 
     83                <cfif TimedCache.exists("primaryKey_" & arguments.name)> 
     84                        <cfset columnList = TimedCache.getValue("primaryKey_" & arguments.name) /> 
     85                <cfelse> 
     86                        <cfstoredproc datasource="#getDsn()#" procedure="sp_pkeys"> 
     87                                <cfprocparam cfsqltype="cf_sql_varchar" scale="384" value="#arguments.name#" /> 
     88                                <cfprocresult name="qPrimaryKey" resultset="1" /> 
     89                        </cfstoredproc> 
     90                         
     91                        <!--- cache the results ---> 
     92                        <cfset columnList = ValueList(qPrimaryKey.column_name) /> 
     93                        <cfset TimedCache.setValue("primaryKey_" & arguments.name, columnList) /> 
     94                </cfif>          
     95                 
     96                <!--- return the data ---> 
     97                <cfreturn columnList /> 
     98        </cffunction> 
     99         
     100        <cffunction name="getColumns" access="public" hint="I return a query of column information on the table." output="false" returntype="query"> 
     101                <cfargument name="name" hint="I am the name of the table inspect." required="yes" type="string" /> 
     102                <cfset var TimedCache = getTimedCache() /> 
     103                <cfset var qColumns = 0 /> 
     104                 
     105                <cfif TimedCache.exists("columns_" & arguments.name)> 
     106                        <cfset qColumns = TimedCache.getValue("columns_" & arguments.name) /> 
     107                <cfelse> 
     108                        <cfstoredproc datasource="#getDsn()#" procedure="sp_columns"> 
     109                                <cfprocparam cfsqltype="cf_sql_varchar" scale="384" value="#arguments.name#" /> 
     110                                <cfprocresult name="qColumns" resultset="1" /> 
     111                        </cfstoredproc> 
     112                         
     113                        <!--- cache the results ---> 
     114                        <cfset TimedCache.setValue("columns_" & arguments.name, qColumns) /> 
     115                </cfif>          
     116                 
     117                <!--- return the data ---> 
     118                <cfreturn qColumns /> 
     119        </cffunction> 
     120         
     121        <cffunction name="getTable" access="public" hint="I return a query of generic information on the table.  If the table doesn't exist I throw an error." output="false" returntype="query"> 
     122                <cfargument name="name" hint="I am the name of the table inspect." required="yes" type="string" /> 
     123                <cfset var TimedCache = getTimedCache() /> 
     124                <cfset var qTable = 0 /> 
     125                 
     126                <cfif TimedCache.exists("table_" & arguments.name)> 
     127                        <cfset qTable = TimedCache.getValue("table_" & arguments.name) /> 
     128                <cfelse> 
     129                        <cfstoredproc datasource="#getDsn()#" procedure="sp_tables"> 
     130                                <cfprocparam cfsqltype="cf_sql_varchar" scale="384" value="#arguments.name#" /> 
     131                                <cfprocresult name="qTable" resultset="1" /> 
     132                        </cfstoredproc> 
     133                         
     134                        <!--- before we go any further, check to make sure the name is a real table ---> 
     135                        <cfif NOT qTable.recordCount> 
     136                                <cfthrow type="reactor.InvalidTableName" 
     137                                        message="Invalid Name Argument" 
     138                                        detail="The name argument must be a valid table or view name which exists in the database." /> 
     139                        </cfif> 
     140                         
     141                        <!--- cache the results ---> 
     142                        <cfset TimedCache.setValue("table_" & arguments.name, qTable) /> 
     143                </cfif>          
     144                 
     145                <!--- return the data ---> 
     146                <cfreturn qTable /> 
     147        </cffunction> 
     148         
     149        <cffunction name="getTableDefinition" access="private" hint="I return the definition for a table." output="false" returntype="struct"> 
     150                <cfargument name="name" hint="I am the name of the table to get the definition for." required="yes" type="string" /> 
     151                <cfset var definition = StructNew() /> 
     152                 
     153                <cfset definition.table = getTable(arguments.name) /> 
     154                <cfset definition.columns = getColumns(arguments.name) /> 
     155                <cfset definition.columnList = ValueList(definition.columns.column_name) /> 
     156                <cfset definition.primaryKeyColumnList = getPrimaryKeyColumnList(arguments.name) /> 
     157                <cfset definition.foreignKeys = getForeignKeys(arguments.name) /> 
     158                <cfset definition.foreignKeysColumnList = ValueList(definition.foreignKeys.foreignColumnName) /> 
     159                <cfset definition.referencingKeys = getReferencingKeys(arguments.name) /> 
     160                <cfset definition.baseTable = getBaseTable(arguments.name, definition.primaryKeyColumnList, definition.foreignKeys) /> 
     161                <cfset definition.baseTableColumns = getColumns(definition.baseTable) /> 
     162                <cfset definition.baseTablePrimaryKeyColumnList = getPrimaryKeyColumnList(definition.baseTable) /> 
     163                 
     164                <!--- return the data ---> 
     165                <cfreturn definition /> 
    84166        </cffunction> 
    85167         
     
    89171                <cfset var structure = 0 /> 
    90172                <cfset var signature = "" /> 
    91                 <cfset var qGetPk = 0 /> 
    92                 <cfset var pkColumns = ValueList(definition.primaryKey.Column_Name) /> 
    93                 <cfset var fkColumns = ValueList(definition.foreignKeys.foreignColumnName) /> 
    94                 <cfset var baseTable = "" /> 
    95173                 
    96174                <cfset var customToBase = "reactor.core.abstractTo" /> 
     
    102180                        <cfset structure = TimedCache.getValue("str_" & arguments.name) /> 
    103181                <cfelse> 
    104                         <!--- check to see if this table "extends" any other table ---> 
    105                         <cfset baseTable = getBaseTable(arguments.name) /> 
    106                          
    107182                        <!--- find out what the generated tables extend ---> 
    108                         <cfif baseTable IS NOT arguments.name> 
    109                                 <cfset customToBase = getObjectName("To", baseTable, false) /> 
    110                                 <cfset customDaoBase = getObjectName("Dao", baseTable, false) /> 
    111                                 <cfset customGatewayBase = getObjectName("Gateway", baseTable, false) /> 
    112                                 <cfset customRecordBase = getObjectName("Record", baseTable, false) /> 
     183                        <cfif definition.baseTable IS NOT arguments.name> 
     184                                <cfset customToBase = getObjectName("To", definition.baseTable, false) /> 
     185                                <cfset customDaoBase = getObjectName("Dao", definition.baseTable, false) /> 
     186                                <cfset customGatewayBase = getObjectName("Gateway", definition.baseTable, false) /> 
     187                                <cfset customRecordBase = getObjectName("Record", definition.baseTable, false) /> 
    113188                        </cfif> 
    114189                         
    115190                        <cfsavecontent variable="structure"> 
    116                                 <table name="<cfoutput>#TitleCase(definition.table.table_name, true)#</cfoutput>" 
    117                                         baseTable="<cfoutput>#baseTable#</cfoutput>" 
     191                                <table 
     192                                        name="<cfoutput>#TitleCase(arguments.name, true)#</cfoutput>" 
     193                                        baseTable="<cfoutput>#definition.baseTable#</cfoutput>" 
    118194                                         
    119195                                        customToBase="<cfoutput>#customToBase#</cfoutput>" 
     
    134210                                                                length="#definition.columns.Length#" 
    135211                                                                default="#definition.columns.Column_Def#" 
    136                                                                 primaryKey="#Iif(ListFindNoCase(pkColumns, definition.columns.Column_Name), DE('true'), DE('false'))#" 
    137                                                                 foreignKey="#Iif(ListFindNoCase(fkColumns, definition.columns.Column_Name), DE('true'), DE('false'))#" 
     212                                                                primaryKey="#Iif(ListFindNoCase(definition.primaryKeyColumnList, definition.columns.Column_Name), DE('true'), DE('false'))#" 
     213                                                                foreignKey="#Iif(ListFindNoCase(definition.foreignKeysColumnList, definition.columns.Column_Name), DE('true'), DE('false'))#" 
    138214                                                                /> 
    139215                                                </cfoutput> 
     
    162238                                                </cfoutput> 
    163239                                        </referencingKeys> 
     240                                        <baseTableColumns> 
     241                                                <cfif definition.baseTable IS NOT arguments.name> 
     242                                                        <cfoutput query="definition.baseTableColumns"> 
     243                                                                <baseTableColumn name="#TitleCase(definition.baseTableColumns.Column_Name, true)#" 
     244                                                                        type="#ListFirst(definition.baseTableColumns.Type_Name, " ")#" 
     245                                                                        overridden="#Iif(ListFindNoCase(definition.columnList, definition.baseTableColumns.Column_Name), DE('true'), DE('false'))#" 
     246                                                                        primaryKey="#Iif(ListFindNoCase(definition.baseTablePrimaryKeyColumnList, definition.baseTableColumns.Column_Name), DE('true'), DE('false'))#" /> 
     247                                                        </cfoutput> 
     248                                                </cfif> 
     249                                        </baseTableColumns> 
    164250                                </table> 
    165251                        </cfsavecontent> 
     
    168254                        <cfset signature = Hash(structure) /> 
    169255                        <cfset structure.XmlRoot.XmlAttributes["signature"] = signature /> 
    170                                                  
     256                         
    171257                        <!--- cache the results ---> 
    172258                        <cfset TimedCache.setValue("str_" & arguments.name, structure) /> 
     
    177263         
    178264        <cffunction name="getBaseTable" access="private" hint="I check to see if this table's primary keys are foreign keys to another table.  If so, I return the name of that table." output="false" returntype="string"> 
    179                 <cfargument name="name" hint="I am the name of the table we're checking for the base table for." required="yes" type="string" /> 
    180                 <cfset var definition = getTableDefinition(arguments.name) />  
    181                 <cfset var primarykey = definition.primarykey />  
    182                 <cfset var foreignKeys = definition.foreignKeys />  
    183                 <cfset var primaryKeyColumnList = "" /> 
     265                <cfargument name="name" hint="I am the name of the table." required="yes" type="string" /> 
     266                <cfargument name="primaryKeyColumnList" hint="I am the query of the primary key" required="yes" type="string" /> 
     267                <cfargument name="foreignKeys" hint="I am the query of foreign keys" required="yes" type="query" /> 
     268                <cfset var TimedCache = getTimedCache() /> 
     269                <cfset var pkColumnList = arguments.primaryKeyColumnList /> 
    184270                <cfset var currentFkName = "" /> 
    185271                <cfset var listLoc = 0 /> 
     272                 
     273                <cfif TimedCache.exists("base_" & arguments.name)> 
     274                        <cfset arguments.name = TimedCache.getValue("base_" & arguments.name) /> 
     275                <cfelse> 
     276                        <!--- loop over the foreign keys ---> 
     277                        <cfloop query="arguments.foreignKeys"> 
     278                                <!--- check to see if we're starting a new fk set ---> 
     279                                <cfif currentFkName IS NOT arguments.foreignKeys.fkName> 
     280                                        <!--- reset some variables ---> 
     281                                        <!--- set the foreign key name.  we'll use this to check to see if we're still on the same foreign key as we loop over the fk query ---> 
     282                                        <cfset currentFkName = arguments.foreignKeys.fkName /> 
     283                                        <!--- get a list of all columns in the primary key ---> 
     284                                        <cfset pkColumnList = arguments.primaryKeyColumnList /> 
     285                                </cfif> 
     286                                 
     287                                <!--- Check to see if the columns in the foreign key named #currentFkName# represent all of the columns in the primary key columns. ---> 
     288                                 
     289                                <!--- if the FK column name exists in the primary key then delete it from the list. ---> 
     290                                <cfset listLoc = ListFindNoCase(pkColumnList, arguments.foreignKeys.thisColumnName) /> 
     291                                <cfif listLoc> 
     292                                        <cfset pkColumnList = ListDeleteAt(pkColumnList, listLoc) /> 
     293                                </cfif> 
     294                                 
     295                                <!--- if we don't have any items left in the primary key column list then all of the columns in the primary key are part of the foreign key to another table. ---> 
     296                                <cfif NOT Len(pkColumnList)> 
     297                                        <!--- the foreign table is a "super" table for this table ---> 
     298                                        <cfset arguments.name = arguments.foreignKeys.foreignTableName /> 
     299                                        <cfbreak /> 
     300                                </cfif> 
     301                        </cfloop> 
    186302 
    187                 <!--- loop over the foreign keys ---> 
    188                 <cfloop query="foreignKeys"> 
    189                         <!--- check to see if we're starting a new fk set ---> 
    190                         <cfif currentFkName IS NOT foreignKeys.fkName> 
    191                                 <!--- reset some variables ---> 
    192                                 <!--- set the foreign key name.  we'll use this to check to see if we're still on the same foreign key as we loop over the fk query ---> 
    193                                 <cfset currentFkName = foreignKeys.fkName /> 
    194                                 <!--- get a list of all columns in the primary key ---> 
    195                                 <cfset primaryKeyColumnList = ValueList(primarykey.column_name) /> 
    196                         </cfif> 
    197                          
    198                         <!--- Check to see if the columns in the foreign key named #currentFkName# represent all of the columns in the primary key columns. ---> 
    199                          
    200                         <!--- if the FK column name exists in the primary key then delete it from the list. ---> 
    201                         <cfset listLoc = ListFindNoCase(primaryKeyColumnList, foreignKeys.thisColumnName) /> 
    202                         <cfif listLoc> 
    203                                 <cfset primaryKeyColumnList = ListDeleteAt(primaryKeyColumnList, listLoc) /> 
    204                         </cfif> 
    205                          
    206                         <!--- if we don't have any items left in the primary key column list then all of the columns in the primary key are part of the foreign key to another table. ---> 
    207                         <cfif NOT Len(primaryKeyColumnList)> 
    208                                 <!--- the foreign table is a "super" table for this table ---> 
    209                                 <cfset arguments.name = foreignKeys.foreignTableName /> 
    210                                 <cfbreak /> 
    211                         </cfif> 
    212                 </cfloop> 
     303                        <!--- cache the results ---> 
     304                        <cfset TimedCache.setValue("base_" & arguments.name, arguments.name) /> 
     305                </cfif>          
    213306                 
    214307                <cfreturn arguments.name /> 
  • reactor/xsl/mssql/gateway.base.xsl

    r1 r3  
    66        <xsl:template match="/"> 
    77&lt;cfcomponent hint="I am the base Gateway object for the <xsl:value-of select="table/@name"/> table.  I am generated.  DO NOT EDIT ME." 
    8         extends="<xsl:choose> 
    9                 <xsl:when test="table/@name = table/@baseTable">reactor.core.abstractGateway</xsl:when> 
    10                 <xsl:when test="table/@name != table/@baseTable"><xsl:value-of select="table/@customGatewayBase" /></xsl:when> 
    11         </xsl:choose>" &gt; 
     8        extends="reactor.core.abstractGateway" &gt; 
    129         
    1310        &lt;cfset variables.signature = "<xsl:value-of select="table/@signature" />" /&gt; 
     
    4441         
    4542        &lt;cffunction name="getByFields" access="public" hint="I return all matching rows from the <xsl:value-of select="table/@name" /> table." output="false" returntype="query"&gt; 
    46                 <xsl:for-each select="table/columns/column">&lt;cfargument name="<xsl:value-of select="@name" />" hint="If provided, I match the provided value to the <xsl:value-of select="@name" /> column." required="no" type="string" /&gt;   
     43        <xsl:choose> 
     44        <xsl:when test="table/@name = table/@baseTable"><xsl:text>      </xsl:text> 
     45                <xsl:for-each select="table/columns/column">&lt;cfargument name="<xsl:value-of select="@name" />" hint="If provided, I match the provided value to the <xsl:value-of select="@name" /> column." required="no" type="string" /&gt; 
    4746                </xsl:for-each> 
     47                &lt;cfset var qGet = 0 /&gt; 
     48                 
    4849                &lt;cfquery name="qGet" datasource="#getDsn()#"&gt; 
    4950                        SELECT  
    50                                 <xsl:for-each select="table/columns/column">"<xsl:value-of select="@name" />"<xsl:if test="position() != last()">,  
     51                                <xsl:for-each select="table/columns/column">[<xsl:value-of select="@name" />]<xsl:if test="position() != last()">,  
    5152                                </xsl:if> 
    5253                                </xsl:for-each> 
     
    5455                        WHERE 1=1 
    5556                                <xsl:for-each select="table/columns/column">&lt;cfif IsDefined('arguments.<xsl:value-of select="@name" />')&gt; 
    56                                         AND "<xsl:value-of select="@name" />" = &lt;cfqueryparam<xsl:choose> 
     57                                        AND [<xsl:value-of select="@name" />] = &lt;cfqueryparam<xsl:choose> 
    5758                                                <xsl:when test="@type = 'int'"> cfsqltype="cf_sql_integer"</xsl:when> 
    5859                                                <xsl:when test="@type = 'bigint'"> cfsqltype="cf_sql_bigint"</xsl:when> 
     
    8485                 
    8586                &lt;cfreturn qGet /&gt; 
     87        </xsl:when> 
     88        <xsl:when test="table/@name != table/@baseTable"><xsl:text>     </xsl:text> 
     89                <xsl:for-each select="table/baseTableColumns/baseTableColumn[@overridden = 'false']">&lt;cfargument name="<xsl:value-of select="@name" />" hint="If provided, I match the provided value to the <xsl:value-of select="@name" /> column in the <xsl:value-of select="../../@baseTable" /> table." required="no" type="string" /&gt; 
     90                </xsl:for-each> 
     91                <xsl:for-each select="table/columns/column">&lt;cfargument name="<xsl:value-of select="@name" />" hint="If provided, I match the provided value to the <xsl:value-of select="@name" /> column in the <xsl:value-of select="../../@name" /> table." required="no" type="string" /&gt; 
     92                </xsl:for-each>&lt;cfset var qGet = 0 /&gt; 
     93                 
     94                &lt;cfabort /&gt; 
     95                 
     96                &lt;cfquery name="qGet" datasource="#getDsn()#"&gt; 
     97                        SELECT  
     98                                <xsl:for-each select="table/baseTableColumns/baseTableColumn[@overridden = 'false']">[<xsl:value-of select="../../@baseTable" />].[<xsl:value-of select="@name" />], 
     99                                </xsl:for-each> 
     100                                <xsl:for-each select="table/columns/column">[<xsl:value-of select="../../@name" />].[<xsl:value-of select="@name" />]<xsl:if test="position() != last()">,  
     101                                </xsl:if> 
     102                                </xsl:for-each> 
     103                        FROM [<xsl:value-of select="table/@name" />] <xsl:if test="count(table/baseTableColumns/baseTableColumn) > 0">JOIN <xsl:value-of select="table/@baseTable" />] 
     104                                ON ..... 
     105                        </xsl:if> 
     106                        WHERE 1=1 
     107                                <xsl:for-each select="table/columns/column">&lt;cfif IsDefined('arguments.<xsl:value-of select="@name" />')&gt; 
     108                                        AND [<xsl:value-of select="@name" />] = &lt;cfqueryparam<xsl:choose> 
     109                                                <xsl:when test="@type = 'int'"> cfsqltype="cf_sql_integer"</xsl:when> 
     110                                                <xsl:when test="@type = 'bigint'"> cfsqltype="cf_sql_bigint"</xsl:when> 
     111                                                <xsl:when test="@type = 'bit'"> cfsqltype="cf_sql_bit"</xsl:when> 
     112                                                <xsl:when test="@type = 'char'"> cfsqltype="cf_sql_char"</xsl:when> 
     113                                                <xsl:when test="@type = 'datetime'"> cfsqltype="cf_sql_date"</xsl:when> 
     114                                                <xsl:when test="@type = 'decimal'"> cfsqltype="cf_sql_decimal"</xsl:when> 
     115                                                <xsl:when test="@type = 'float'"> cfsqltype="cf_sql_float"</xsl:when> 
     116                                                <xsl:when test="@type = 'money'"> cfsqltype="cf_sql_money"</xsl:when> 
     117                                                <xsl:when test="@type = 'nchar'"> cfsqltype="cf_sql_char"</xsl:when> 
     118                                                <xsl:when test="@type = 'numeric'"> cfsqltype="cf_sql_numeric"</xsl:when> 
     119                                                <xsl:when test="@type = 'nvarchar'"> cfsqltype="cf_sql_varchar"</xsl:when> 
     120                                                <xsl:when test="@type = 'real'"> cfsqltype="cf_sql_real"</xsl:when> 
     121                                                <xsl:when test="@type = 'smalldatetime'"> cfsqltype="cf_sql_date"</xsl:when> 
     122                                                <xsl:when test="@type = 'smallint'"> cfsqltype="cf_sql_smallint"</xsl:when> 
     123