Not of type Numeric when it damn well is...
I have a problem, and it's ColdFusion... We're working on some complex object interaction, and moving data in and out of our objects. Part of the "moving in" part involves building out a structure of arguments based on query columns, and then passing them all in via the ArgumentCollection. Unfortunately, ColdFusion doesn't love us here at lynda.com... It's pitching a fit and saying that our IDs aren't of type numeric, when I know damn well that they are (grumble grumble)... To demonstrate my point I've come up with the following code example. This fails every time for me:14 Comments
Daniel Short wrote on 01/04/07 2:24 PM
YupDanilo wrote on 01/04/07 3:27 PM
Hey man, hope all is well! My first thought was that the query cell value that is returned is actually some Java data type, not the integer you're telling it to be. So I tried dumping: IsNumeric(TestStruct["ID"]) and it output NO so CF wasn't seeing it as numeric. So I thought instead of using the default for pulling the query row value: rs[col] trying rs[col][1] to indicate pulling the first row and then IsNumeric(TestStruct["ID"]) did return YES. As I don't have access to your CFC...or do I? :-) you'll have to try it to see how it'll work for your situation. Let me know. PS: Not that I post here so much, but how about making the textarea a little wider and taller?Daniel Short wrote on 01/04/07 3:27 PM
Nail, meet hammer :)Adrian J. Moreno wrote on 01/05/07 1:34 PM
I'd say the problem is that ArgumentCollection is an attribute of cfinvoke and (without seeing the code for test.cfc) not an argument of the init() method. I imagine that init() has two arguments: {cfargument name="ID" type="numeric" required="true" /} {cfargument name="FirstName" type="string" required="true" /} Since you're passing in a named argument called ArgumentCollection and no named argument called ID, the error is thrown as expected. If you instead use {cfset MyObject = CreateObject("component", "test").init(ID = TestStruct.ID, FirstName = TestStruct.FirstName) /} the object will be created correctly. HTHDaniel Short wrote on 01/05/07 1:35 PM
Actually the argumentcollection allows you to pass in an entire struct of arguments without having to name them all :). It came down to me not referencing the proper row of the recordset.TAmi wrote on 01/06/07 3:08 PM
Hi Dan... I have had the same issue before, but I am surprised you are able to CFDUMP an CFC object. I can never get my CFMX to play nice. I usually have toDaniel Short wrote on 01/06/07 3:08 PM
Interesting issue... not sure what would be going on there...DAD wrote on 01/06/07 3:27 PM
I think that if you turn your = sign over, then take a backward < sign and turn it around to make a >, then take and flip your [ right side up, then leave all the comma's where they are, it ought to work perfectly. Hope this helps, DadDaniel Short wrote on 01/06/07 3:27 PM
Thanks dad, that worked perfectly :).Paul wrote on 01/08/07 11:45 AM
You are using cfmx6 correct? If so this is a known bug and you may be able to get around it by using the javaCast function when setting the id. In general when you create or edit a query in cfmx6 you may have problems when checking the type of the data.Daniel Short wrote on 01/08/07 11:46 AM
Actually it turned out to be me not referencing the column correctly. I needed this: <cfset TestStruct[col] = rs[col][1] />Bryan Ashcraft wrote on 01/15/07 2:38 PM
Total shot in the dark here, but could be the way you are addressing the value? For instance: arguments.testStruct.id vs arguments.testStruct[1]Daniel Short wrote on 01/15/07 2:38 PM
Yep, you got it Bryan...
charlie griefer wrote on 01/04/07 2:24 PM