davequested
07/23/2024, 3:21 AMseancorfield
seancorfield
davequested
07/23/2024, 7:27 AMaliaspooryorik
aliaspooryorik
davequested
07/23/2024, 7:28 AMdavequested
07/23/2024, 7:28 AMdavequested
07/23/2024, 7:29 AMaliaspooryorik
davequested
07/23/2024, 7:31 AMaliaspooryorik
aliaspooryorik
if (x == 1 && y > 2 || a > 3 ) {..SQL WHERE...} type stuff?davequested
07/23/2024, 7:35 AMdavequested
07/23/2024, 7:36 AMaliaspooryorik
aliaspooryorik
davequested
07/23/2024, 7:39 AMaliaspooryorik
<cfif includePrices(x,y)>pricescolumn,</cfif>aliaspooryorik
aliaspooryorik
davequested
07/23/2024, 7:42 AMaliaspooryorik
includePrices in it's own CFC so that the logic is separate (and therefore testable and reusable)davequested
07/23/2024, 7:44 AMaliaspooryorik
davequested
07/23/2024, 7:45 AMdavequested
07/23/2024, 7:45 AMaliaspooryorik
The only reason they are there is to deal with this limitation!Disagree - it makes you code testable - and as professionals we should all be writing tests. Ask the crowdstrike people about testing :D
Adam Cameron
buildTheStateemnt() {
buildTheSelect()
buildTheFrom()
// etc
}
Refactoring (and keeping one's methods small and doing one thing) is not about reusability btw. it's clarity and testability.Adam Cameron
You now have to work your way through a load of functions to edit a SQL statement.Nope. Now you just have to look at the part of the SQL statement you currently need to focus on, and don't have to worry about the rest of it.
davequested
07/23/2024, 7:52 AMdavequested
07/23/2024, 7:53 AMAdam Cameron
SELECT id, name
FROM sometable
WHERE something = 1
Would never be written
buildTheStateemnt() {
buildTheSelect()
buildTheFrom()
buildTheWhere()
}
False equivalence.
No-one's talking about refactoring a 50-byte SQL statement to use the template pattern.
It's cos you've let it get away from you AND THE CODE NOW DOESN'T EVEN COMPILE (FFS!!!) that you are needing to ask how to mitigate it.Adam Cameron
Adam Cameron
Dave Merrill
07/23/2024, 12:50 PMAdam Cameron
<cfquery>
<cfinclude><!--- params in here --->
</cfquery>
We had a lot of that back when I used to write code like Dave's (at the same company as Dave, even... hence him knowing I'm, nuts).
Haven't tried anything like that for 15yrs or so though.
But one only needs <cfqueryparam> if one still uses <cfquery>. Not needed with queryExecute (or even with the Query.cfc thing, from memory). It's a bit of an old-school approach to things.Adam Cameron
<!--- test.cfm --->
<cfquery name="numbers">
SELECT *
FROM numbers
<cfinclude template="./filters.cfm">
ORDER BY id
</cfquery>
<cfdump var="#numbers#">
<!--- filters.cfm --->
WHERE id > <cfqueryparam value="5" cfsqltype="CF_SQL_INTEGER">Adam Cameron
Adam Cameron
en value should be six. But you get the idea)Dave Merrill
07/23/2024, 2:09 PMMark Takata (Adobe)
07/23/2024, 3:44 PMaliaspooryorik
Mark Takata (Adobe)
07/23/2024, 3:51 PMaliaspooryorik
Mark Takata (Adobe)
07/23/2024, 3:53 PMgamesover
07/24/2024, 4:12 PMseancorfield
davequested
07/25/2024, 10:11 PM