I have my "setter" deal with the incompatability. For instance, as someone else said I might have a predefined, application wide value that is a "null" integer (a magic number like -1 for instance)
my setter takes a string but my getter returns a numeric. If my setter gets a non-numeric value then it sets the value in the instance scope to be equal to my magic number. If it gets a numeric then it keeps it what it is. My getter always returns a numeric. Bill On 9/19/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > This situation holds true for any data types other than strings because > CF treats nulls as strings. So, for those who use getters to return > instance data, how do you handle situations where the data may contain > nulls yet your getters are designed to return a specific data type? > > Tom > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Schreck, Thomas (PPC) > Sent: Monday, September 19, 2005 7:57 AM > To: [email protected] > Subject: RE: [CFCDev] <cffunction> return type > > The specific situation I'm running into is returning numeric values from > the database. I use getter/setters to access instance data. If my > getter returns a numeric value from a field in the database whose data > type is int but value is null then CF balks. > > CF treats nulls like empty strings. I suppose I need to make my getters > a little more intelligent. > > Thanks - Tom > > > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Barry Beattie > Sent: Saturday, September 17, 2005 6:38 AM > To: [email protected] > Subject: Re: [CFCDev] <cffunction> return type > > it depends on what the number is > > if it's an identifier/autonumber, it's a system generated value so > therefore you control the datatype. so... return it as a string. NULL > is an empty string. ie it could be replaced with a GUID which is a > string anyway. So it's not a "number" but a "numeral" > > if you're using the number for calculating however (eg a count or > quantity - the only time I'd return a number is for calculating) then > could NULL be zero? > > what is the number is used for? > > just my 2c > > On 9/17/05, Dawson, Michael <[EMAIL PROTECTED]> wrote: > > No one mentioned this, so I will. Why not throw an exception when the > > value is not numeric? > > > > Since your returntype is "numeric", CF itself will throw the > exception. > > Can't you just catch that error when it happens? > > > > M!ke > > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > > Behalf Of [EMAIL PROTECTED] > > Sent: Friday, September 16, 2005 1:56 PM > > To: [email protected] > > Subject: RE: [CFCDev] <cffunction> return type > > > > I agree, but nulls are valid options in the database. I like the > > ability to restrict the return type of a function and think altering > > that to string or any to accommodate nulls is a step backwards and > could > > have negative consequences. > > > > Thanks - Tom > > > > > > ---------------------------------------------------------- > > You are subscribed to cfcdev. To unsubscribe, send an email to > [email protected] with the words 'unsubscribe cfcdev' as the subject of > the email. > > > > CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting > (www.cfxhosting.com). > > > > CFCDev is supported by New Atlanta, makers of BlueDragon > > http://www.newatlanta.com/products/bluedragon/index.cfm > > > > An archive of the CFCDev list is available at > www.mail-archive.com/[email protected] > > > > > > > > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email to > [email protected] with the words 'unsubscribe cfcdev' as the subject of > the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting > (www.cfxhosting.com). > > CFCDev is supported by New Atlanta, makers of BlueDragon > http://www.newatlanta.com/products/bluedragon/index.cfm > > An archive of the CFCDev list is available at > www.mail-archive.com/[email protected] > > > > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email to > [email protected] with the words 'unsubscribe cfcdev' as the subject of > the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting > (www.cfxhosting.com). > > CFCDev is supported by New Atlanta, makers of BlueDragon > http://www.newatlanta.com/products/bluedragon/index.cfm > > An archive of the CFCDev list is available at > www.mail-archive.com/[email protected] > > > > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email to > [email protected] with the words 'unsubscribe cfcdev' as the subject of the > email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting > (www.cfxhosting.com). > > CFCDev is supported by New Atlanta, makers of BlueDragon > http://www.newatlanta.com/products/bluedragon/index.cfm > > An archive of the CFCDev list is available at > www.mail-archive.com/[email protected] > > > -- [EMAIL PROTECTED] http://blog.rawlinson.us If you want Gmail - just ask. ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
