[flexcoders] Re: AIR SQLLite, ints, and NULLs
--- In flexcoders@yahoogroups.com, "Charlie Hubbard" <[EMAIL PROTECTED]> wrote: > > Ok thanks Johannes. Very good point. Number's can't really be NULL either. > However, it just so happens that NaN is interpreted as NULL to the datatype > conversion layer in AIR and it just happens to work out. Maybe this slight > difference between NaN and NULL doesn't really matter, but it's good to know > that it exists. > My temptation is to write a real object that encapsulates int's as a true > Object data type that can really be NULL, but the draw back here is that it > would be incompatible with AIR's handy databinding (itemClass on > SQLStatement since AIR will convert database integers to Numbers instead of > my abstraction). > > I guess more investigation is needed in these matters. I don't see why you can't just use myInt==undefined?null:myInt; That also avoids the possibility of strange rounding errors you set yourself up for when you use Number instead of int. But hey maybe there's something special about sqlLite's version of SQL that makes it impossible to perform evaluations like that in the statement...?
Re: [flexcoders] Re: AIR SQLLite, ints, and NULLs
Ok thanks Johannes. Very good point. Number's can't really be NULL either. However, it just so happens that NaN is interpreted as NULL to the datatype conversion layer in AIR and it just happens to work out. Maybe this slight difference between NaN and NULL doesn't really matter, but it's good to know that it exists. My temptation is to write a real object that encapsulates int's as a true Object data type that can really be NULL, but the draw back here is that it would be incompatible with AIR's handy databinding (itemClass on SQLStatement since AIR will convert database integers to Numbers instead of my abstraction). I guess more investigation is needed in these matters. Charlie On Mon, Nov 24, 2008 at 2:26 PM, Johannes Nel <[EMAIL PROTECTED]>wrote: > on debug level it evaluates to NaN, which should insert as NULL. > but then remember > var n:Number; // == NaN > var p:Number = n + 1;//==NaN > > var q:int = n+1;//==0 > > > On Mon, Nov 24, 2008 at 9:01 PM, Charlie Hubbard < > [EMAIL PROTECTED]> wrote: > >> So if I can sum up your email very clearly. I'd say: >> >> DO NOT use int, use Number, because that's what Air's database connection >> layer is going to return you. >> >> If you use int data type for fields you'll get zeros. With Number it's >> will propagate NULLs correctly. >> >> Thanks, >> Charlie >> >> On Mon, Nov 24, 2008 at 12:18 AM, jason_williams_mm < >> [EMAIL PROTECTED]> wrote: >> >>> --- In flexcoders@yahoogroups.com , >>> "Charlie Hubbard" >>> <[EMAIL PROTECTED]> wrote: >>> > >>> > I've read over all of the docs on Air, but there seems to be a missing >>> > discussion around NULL values in SQLLite and how those map back to >>> > datatypes. What I've found is that if I have an int field type I >>> can't get >>> > a NULL value to ever get inserted into the SQLLite. It just ends up >>> > inserting 0 (zero). In Java we'd just convert to using a true >>> Object like >>> > Integer class, and that would handle this problem for us. What is the >>> > equivalent with Actionscript? If you want NULLs and numbers what is an >>> > object and a number, and will Air convert between the two correctly? >>> > >>> > Thanks >>> > Charlie >>> > >>> >>> It would help to see the code that you are using, however, the >>> following code gives the same results in both 1.5 and 1.1: >>> >>> >>> http://www.adobe.com/2006/mxml"; >>> layout="absolute" creationComplete="run()"> >>> >>> >>> >>> >>> >>> -- trace output -- >>> >>> (Array)#0 >>> [0] (Object)#1 >>> id = (null) >>> [1] (Object)#2 >>> id = 1 >>> [2] (Object)#3 >>> id = 2 >>> [3] (Object)#4 >>> id = 3 >>> >>> Each of the values returned in the object is a Number. Hope that >>> helps some. >>> >>> jw >>> >>> >> > > > -- > j:pn > \\no comment > > >
Re: [flexcoders] Re: AIR SQLLite, ints, and NULLs
on debug level it evaluates to NaN, which should insert as NULL.but then remember var n:Number; // == NaN var p:Number = n + 1;//==NaN var q:int = n+1;//==0 On Mon, Nov 24, 2008 at 9:01 PM, Charlie Hubbard <[EMAIL PROTECTED]>wrote: > So if I can sum up your email very clearly. I'd say: > > DO NOT use int, use Number, because that's what Air's database connection > layer is going to return you. > > If you use int data type for fields you'll get zeros. With Number it's > will propagate NULLs correctly. > > Thanks, > Charlie > > On Mon, Nov 24, 2008 at 12:18 AM, jason_williams_mm < > [EMAIL PROTECTED]> wrote: > >> --- In flexcoders@yahoogroups.com , >> "Charlie Hubbard" >> <[EMAIL PROTECTED]> wrote: >> > >> > I've read over all of the docs on Air, but there seems to be a missing >> > discussion around NULL values in SQLLite and how those map back to >> > datatypes. What I've found is that if I have an int field type I >> can't get >> > a NULL value to ever get inserted into the SQLLite. It just ends up >> > inserting 0 (zero). In Java we'd just convert to using a true >> Object like >> > Integer class, and that would handle this problem for us. What is the >> > equivalent with Actionscript? If you want NULLs and numbers what is an >> > object and a number, and will Air convert between the two correctly? >> > >> > Thanks >> > Charlie >> > >> >> It would help to see the code that you are using, however, the >> following code gives the same results in both 1.5 and 1.1: >> >> >> http://www.adobe.com/2006/mxml"; >> layout="absolute" creationComplete="run()"> >> >> >> >> >> >> -- trace output -- >> >> (Array)#0 >> [0] (Object)#1 >> id = (null) >> [1] (Object)#2 >> id = 1 >> [2] (Object)#3 >> id = 2 >> [3] (Object)#4 >> id = 3 >> >> Each of the values returned in the object is a Number. Hope that >> helps some. >> >> jw >> >> > > -- j:pn \\no comment
Re: [flexcoders] Re: AIR SQLLite, ints, and NULLs
So if I can sum up your email very clearly. I'd say: DO NOT use int, use Number, because that's what Air's database connection layer is going to return you. If you use int data type for fields you'll get zeros. With Number it's will propagate NULLs correctly. Thanks, Charlie On Mon, Nov 24, 2008 at 12:18 AM, jason_williams_mm < [EMAIL PROTECTED]> wrote: > --- In flexcoders@yahoogroups.com , > "Charlie Hubbard" > <[EMAIL PROTECTED]> wrote: > > > > I've read over all of the docs on Air, but there seems to be a missing > > discussion around NULL values in SQLLite and how those map back to > > datatypes. What I've found is that if I have an int field type I > can't get > > a NULL value to ever get inserted into the SQLLite. It just ends up > > inserting 0 (zero). In Java we'd just convert to using a true > Object like > > Integer class, and that would handle this problem for us. What is the > > equivalent with Actionscript? If you want NULLs and numbers what is an > > object and a number, and will Air convert between the two correctly? > > > > Thanks > > Charlie > > > > It would help to see the code that you are using, however, the > following code gives the same results in both 1.5 and 1.1: > > > http://www.adobe.com/2006/mxml"; > layout="absolute" creationComplete="run()"> > > > > > > -- trace output -- > > (Array)#0 > [0] (Object)#1 > id = (null) > [1] (Object)#2 > id = 1 > [2] (Object)#3 > id = 2 > [3] (Object)#4 > id = 3 > > Each of the values returned in the object is a Number. Hope that > helps some. > > jw > > >
[flexcoders] Re: AIR SQLLite, ints, and NULLs
--- In flexcoders@yahoogroups.com, "Charlie Hubbard" <[EMAIL PROTECTED]> wrote: > > I've read over all of the docs on Air, but there seems to be a missing > discussion around NULL values in SQLLite and how those map back to > datatypes. What I've found is that if I have an int field type I can't get > a NULL value to ever get inserted into the SQLLite. It just ends up > inserting 0 (zero). In Java we'd just convert to using a true Object like > Integer class, and that would handle this problem for us. What is the > equivalent with Actionscript? If you want NULLs and numbers what is an > object and a number, and will Air convert between the two correctly? > > Thanks > Charlie > It would help to see the code that you are using, however, the following code gives the same results in both 1.5 and 1.1: http://www.adobe.com/2006/mxml"; layout="absolute" creationComplete="run()"> -- trace output -- (Array)#0 [0] (Object)#1 id = (null) [1] (Object)#2 id = 1 [2] (Object)#3 id = 2 [3] (Object)#4 id = 3 Each of the values returned in the object is a Number. Hope that helps some. jw
[flexcoders] Re: AIR SQLLite, ints, and NULLs
--- In flexcoders@yahoogroups.com, "Charlie Hubbard" <[EMAIL PROTECTED]> wrote: > > Thanks Amy, but I was really asking for what I can use as a substitute data > type for an int since you can't have NULLs for an int. So far from what I'm > finding is I can use Number in place of int and also get a null value for a > Number into the DB. At least it seems that way so far. If I change all of > my int's to Number's then I start getting NULLs as expected for values that > are unset. So I guess I really trying to validate that fact with other > Actionscripters out there to see if this is acceptable or if not is there a > better option. Can I use Number place of int and not run into any problems > down the road? I think the main issues you could face are that Numbers use sllightly more memory than ints and that there's some possibility that you could wind up with a decimal value in there accidentally. Sometimes you get strange rounding errors with numbers due to precision problems with how computers store numbers. Try something like: yourNum==undefined?null:yourNum in whatever statement you're using to populate the database. HTH; Amy
RE: [flexcoders] Re: AIR SQLLite, ints, and NULLs
I was having troubles with this also (using sqlite in AIR). I did not realise that ints dont have NULLS and Numbers do, so will change my ints to Numbers as well if that is deemed the proper thing to Thanks! _ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Charlie Hubbard Sent: Monday, November 24, 2008 9:02 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Re: AIR SQLLite, ints, and NULLs Thanks Amy, but I was really asking for what I can use as a substitute data type for an int since you can't have NULLs for an int. So far from what I'm finding is I can use Number in place of int and also get a null value for a Number into the DB. At least it seems that way so far. If I change all of my int's to Number's then I start getting NULLs as expected for values that are unset. So I guess I really trying to validate that fact with other Actionscripters out there to see if this is acceptable or if not is there a better option. Can I use Number place of int and not run into any problems down the road? Charlie On Sun, Nov 23, 2008 at 1:37 PM, Amy mailto:[EMAIL PROTECTED]> bellsouth.net> wrote: --- In [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com> ups.com, "Charlie Hubbard" <[EMAIL PROTECTED]> wrote: > > I've read over all of the docs on Air, but there seems to be a missing > discussion around NULL values in SQLLite and how those map back to > datatypes. What I've found is that if I have an int field type I can't get > a NULL value to ever get inserted into the SQLLite. It just ends up > inserting 0 (zero). In Java we'd just convert to using a true Object like > Integer class, and that would handle this problem for us. What is the > equivalent with Actionscript? If you want NULLs and numbers what is an > object and a number, and will Air convert between the two correctly? I don't believe null is an acceptable value for an int in Actionscript 3, so as long as you're using an int datatype, you'll have to check for maybe undefined or something and insert null vs. the actual variable value. Check the docs for the specifics of what the "empty" value is for int. HTH; Amy No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.175 / Virus Database: 270.9.9/1806 - Release Date: 11/22/2008 6:59 PM
Re: [flexcoders] Re: AIR SQLLite, ints, and NULLs
Thanks Amy, but I was really asking for what I can use as a substitute data type for an int since you can't have NULLs for an int. So far from what I'm finding is I can use Number in place of int and also get a null value for a Number into the DB. At least it seems that way so far. If I change all of my int's to Number's then I start getting NULLs as expected for values that are unset. So I guess I really trying to validate that fact with other Actionscripters out there to see if this is acceptable or if not is there a better option. Can I use Number place of int and not run into any problems down the road? Charlie On Sun, Nov 23, 2008 at 1:37 PM, Amy <[EMAIL PROTECTED]> wrote: > --- In flexcoders@yahoogroups.com , > "Charlie Hubbard" > <[EMAIL PROTECTED]> wrote: > > > > I've read over all of the docs on Air, but there seems to be a missing > > discussion around NULL values in SQLLite and how those map back to > > datatypes. What I've found is that if I have an int field type I > can't get > > a NULL value to ever get inserted into the SQLLite. It just ends up > > inserting 0 (zero). In Java we'd just convert to using a true Object > like > > Integer class, and that would handle this problem for us. What is the > > equivalent with Actionscript? If you want NULLs and numbers what is > an > > object and a number, and will Air convert between the two correctly? > > I don't believe null is an acceptable value for an int in Actionscript > 3, so as long as you're using an int datatype, you'll have to check for > maybe undefined or something and insert null vs. the actual variable > value. Check the docs for the specifics of what the "empty" value is > for int. > > HTH; > > Amy > > >
[flexcoders] Re: AIR SQLLite, ints, and NULLs
--- In flexcoders@yahoogroups.com, "Charlie Hubbard" <[EMAIL PROTECTED]> wrote: > > I've read over all of the docs on Air, but there seems to be a missing > discussion around NULL values in SQLLite and how those map back to > datatypes. What I've found is that if I have an int field type I can't get > a NULL value to ever get inserted into the SQLLite. It just ends up > inserting 0 (zero). In Java we'd just convert to using a true Object like > Integer class, and that would handle this problem for us. What is the > equivalent with Actionscript? If you want NULLs and numbers what is an > object and a number, and will Air convert between the two correctly? I don't believe null is an acceptable value for an int in Actionscript 3, so as long as you're using an int datatype, you'll have to check for maybe undefined or something and insert null vs. the actual variable value. Check the docs for the specifics of what the "empty" value is for int. HTH; Amy