On Mar 26, 3:46 am, Peter Etchells <peter.a.etche...@gmail.com> wrote:
> Thanks for taking the time to look at this problem.
>
> len(dx.executesql('SELECT * from fields'))
> gave 43815, ie the correct answer.
>
> I finally realized it was because the anki application for some reason
> had a negative id about 1/3 of the records.

you need to look into this some more...

For 16 bit integers, signed int will be 32767, or 0x7fff

If you add one to this binary number you wind up with the top bit -
i.e. the "SIGN" bit - set;  this _can_ be interpreted as a negative
number (-maxit for 16 bit integers).

Let me put this another way:  for the number of records you are
referring to, the next index after 32767 would be 32768:  a negative
number for a 16-bit, signed integer (so no big surprise).   By sign
extension rules,  a negative number will keep its value when "cast" to
a larger integer.

Since you have this definition - Field('fieldModelId', 'Integer')  -
rather than a reference, you are not sure what is going on (and,
probably, neither is python, or perhaps the sqlite driver).

You should use a proper declaration, so you get rid of this side
affect of inappropriately declaring a reference as an integer, and
tell us - is it DAL doing this conversion?   Is it the sqlite driver?

- Yarko


>
> I was just using the default query dx.fields.id > 0, which filtered
> these out. It had nothing to do the the empty value field.
>
> Thanks for sorting this out for me. I enjoy using web2py.
>
> Regards
> Peter Etchells

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to