Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Re : Validate that IntegerField is a valid Signed value
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Cal Leeming [Simplicity Media Ltd]  
View profile  
 More options Apr 30 2011, 2:31 pm
From: "Cal Leeming [Simplicity Media Ltd]" <cal.leem...@simplicitymedialtd.co.uk>
Date: Sat, 30 Apr 2011 19:31:21 +0100
Local: Sat, Apr 30 2011 2:31 pm
Subject: Re: Re : Validate that IntegerField is a valid Signed value

Hey Mathieu,

Thanks for taking the time to reply. I'm starting to see now why the core
devs are reluctant to modify IntegerField.

I'm wondering if maybe Django should have a SignedIntegerField and
UnsignedIntegerField as part of the core (for those that wish to have
enforced 32-bit integers), with the same INT_MIN and INT_MAX from limits.h (
http://en.wikipedia.org/wiki/Limits.h). But there again, would this be
considered un-pythonic or against the ethics of Django?

I guess really it should be up to MySQL to have strict mode by default. But,
as this is unlikely to happen, could we perhaps consider having a commented
out entry in the settings.py file that allows you to set strict mode for all
SQL connections? Or, perhaps a documentation change, which explains easily
to the user how to do it (Kinda like the storage_engine thing on
http://docs.djangoproject.com/en/dev/ref/databases/#creating-your-tables ) .

Let me know your thoughts :)

Cal

On Sat, Apr 30, 2011 at 6:32 PM, Mathieu AGOPIAN
<mathieu.agop...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mathieu AGOPIAN  
View profile  
 More options May 1 2011, 6:58 am
From: Mathieu AGOPIAN <mathieu.agop...@gmail.com>
Date: Sun, 1 May 2011 03:58:24 -0700 (PDT)
Local: Sun, May 1 2011 6:58 am
Subject: Re: Re : Validate that IntegerField is a valid Signed value
For reference, this discussion is linked to
http://groups.google.com/group/django-developers/browse_thread/thread...
and to the ticket http://code.djangoproject.com/ticket/15923

Cal,

The only thing that i could imagine regarding "fixing" this issue
would indeed be a documentation addition in the MySQL (or MySQLdb)
part of the http://docs.djangoproject.com/en/dev/ref/databases/ page,
explaining the possible issue with integers that are too large to fit
in the appropriate mysql column (though i'm not sure how all this
works, as i'm far from a MySQL or ORM expert).
Specifically, explaining how to set the sql_mode to "traditional" as
explained by kmtracey (http://code.djangoproject.com/ticket/
15923#comment:10) I believe.

Let's see if there's anyone reading this mailing list showing interest
about this, and/or feel free to create a feature request on trac, and
see if it's accepted.

On a side note, as python doesn't seem to have any issue with large
integers, i guess you could subclass the IntegerField, and add to it's
validation a check to see if the resulting integer can be stored in a
32 bits using either a simple comparison, like the following:
    -int('1' * 31, 2) < int(field_value) < int('1' * 31, 2)

Mathieu

On Apr 30, 8:31 pm, "Cal Leeming [Simplicity Media Ltd]"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cal Leeming [Simplicity Media Ltd]  
View profile  
 More options May 1 2011, 8:42 am
From: "Cal Leeming [Simplicity Media Ltd]" <cal.leem...@simplicitymedialtd.co.uk>
Date: Sun, 1 May 2011 13:42:00 +0100
Subject: Re : Validate that IntegerField is a valid Signed value

Yeah, subclassing sounds the way forward. I was thinking something like:

SignedIntegerField = IntegerField(min_value=–2147483648, max_value=
2147483647)
UnsignedIntegerField = IntegerField(min_value=0, max_value=4294967295)

Do you think there would be much chance in having these two field types
included in the core? If so, should I create a patch for fields.py and
submit??

As for the MySQL strict mode, I'll submit a documentation patch, and see if
it gets accepted :)

On Sun, May 1, 2011 at 11:58 AM, Mathieu AGOPIAN
<mathieu.agop...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mathieu AGOPIAN  
View profile  
 More options May 1 2011, 9:19 am
From: Mathieu AGOPIAN <mathieu.agop...@gmail.com>
Date: Sun, 1 May 2011 06:19:03 -0700 (PDT)
Local: Sun, May 1 2011 9:19 am
Subject: Re: Re : Validate that IntegerField is a valid Signed value
I really can't tell if those two new fields would be integrated in
core, either wait for feedback here, and/or give it a try with a
ticket (and i'm pretty sure it'll land in "Design Decision Needed").

On May 1, 2:42 pm, "Cal Leeming [Simplicity Media Ltd]"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Fwd: Re : Validate that IntegerField is a valid Signed value" by Cal Leeming [Simplicity Media Ltd]
Cal Leeming [Simplicity Media Ltd]  
View profile  
 More options May 1 2011, 9:21 am
From: "Cal Leeming [Simplicity Media Ltd]" <cal.leem...@simplicitymedialtd.co.uk>
Date: Sun, 1 May 2011 14:21:32 +0100
Local: Sun, May 1 2011 9:21 am
Subject: Fwd: Re : Validate that IntegerField is a valid Signed value

Done

[Django] #15939 <http://code.djangoproject.com/ticket/15939>:
SignedIntegerField? <http://code.djangoproject.com/wiki/SignedIntegerField>
 / UnsignedIntegerField?<http://code.djangoproject.com/wiki/UnsignedIntegerField>
as
part of the core fields.py

[Django] #15940 <http://code.djangoproject.com/ticket/15940>: Patch database
documentation to explain why using sql_mode=strict is important

On Sun, May 1, 2011 at 2:19 PM, Mathieu AGOPIAN
<mathieu.agop...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »