Status/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Devin Holloway / Devin Holloway (Devin Holloway)
Created: 07/07/2009
Components: Language, CF Component
Versions: 9.0
Failure Type: Unspecified
Found In Build/Fixed In Build: 0000 / 244339
Priority/Frequency: Normal / Unknown
Locale/System: English / Platforms All
Vote Count: 1
Problem:
Strict persistent CFC with integer id needs unsavedvalue.
I keep running into this gotcha. If you create a strict CFC with a typical integer id:
/**
* @fieldtype id
* @generator native
*/
property int accountId;
Then create new instance of it and save it:
<cfset account = EntityNew("Account")>
<cfset EntitySave(account)>
It does not show up in the database. If you dump it right before saving it, you’ll see that accountId is defaulted to 0... which I’m assuming is because of the strict int datatype. Then, because the id has a value, even though you never set it, ORM tries to update it and doesn’t find the record to update. I’m sure I would have seen this if I looked in at the SQL executed in the console (which I rarely do since it’s such a PITA). In anycase, the obvious way to handle this is to set the "unsavedvalue" attribute to 0 as well.
So I’m wondering, would this be a very common "gotcha" that could/should be remedied a little? One thought would be if strict int datatypes in persistent CFCs defaulted to an unsavedvalue of 0. Or would this be a little too much "hand-holding", considering that normally only advanced developers would be using strict CFCs? Maybe it’s just a case where clear documentation would be enough.
Method:
Result:
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3039174
External Customer Info:
External Company:
External Customer Name: Devin Holloway
External Customer Email: 5E060FD6422E831A992015D5
External Test Config: 07/07/2009
Attachments:
Comments: