Re: [Django] #12137: Postgres 8.4 imposes strict typing on CharField and TextField

2010-01-10 Thread Django
#12137: Postgres 8.4 imposes strict typing on CharField and TextField
---+
  Reporter:  russellm  | Owner:  nobody
Status:  closed| Milestone:  1.2   
 Component:  Database layer (models, ORM)  |   Version:  1.1   
Resolution:  fixed |  Keywords:
 Stage:  Accepted  | Has_patch:  1 
Needs_docs:  0 |   Needs_tests:  1 
Needs_better_patch:  0 |  
---+
Changes (by carljm):

  * status:  new => closed
  * resolution:  => fixed

Comment:

 Actually a dupe of #10015, fixed in r12150.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.




Re: [Django] #12137: Postgres 8.4 imposes strict typing on CharField and TextField

2009-11-03 Thread Django
#12137: Postgres 8.4 imposes strict typing on CharField and TextField
---+
  Reporter:  russellm  | Owner:  nobody
Status:  new   | Milestone:  1.2   
 Component:  Database layer (models, ORM)  |   Version:  1.1   
Resolution:|  Keywords:
 Stage:  Accepted  | Has_patch:  0 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Comment (by ke1g):

 The patch mfields.diff, above, is somewhat tested against PostgreSQL's 8.4
 and 8.1.11.  That is, my project now works against both versions of the
 database, having looked at pages in several apps (pages cms, profiles,
 admin, a custom app).
 It is above my djangoiness to know whether it would have been better to
 have used "str" than "unicode" in the patch (two places).
 I certainly can't promise that it doesn't break something else, but it
 seems "correct" to me.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #12137: Postgres 8.4 imposes strict typing on CharField and TextField

2009-11-03 Thread Django
#12137: Postgres 8.4 imposes strict typing on CharField and TextField
---+
  Reporter:  russellm  | Owner:  nobody
Status:  new   | Milestone:  1.2   
 Component:  Database layer (models, ORM)  |   Version:  1.1   
Resolution:|  Keywords:
 Stage:  Accepted  | Has_patch:  1 
Needs_docs:  0 |   Needs_tests:  1 
Needs_better_patch:  0 |  
---+
Changes (by russellm):

  * has_patch:  0 => 1
  * needs_tests:  0 => 1

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #12137: Postgres 8.4 imposes strict typing on CharField and TextField

2009-11-03 Thread Django
#12137: Postgres 8.4 imposes strict typing on CharField and TextField
---+
  Reporter:  russellm  | Owner:  nobody
Status:  new   | Milestone:  1.2   
 Component:  Database layer (models, ORM)  |   Version:  1.1   
Resolution:|  Keywords:
 Stage:  Accepted  | Has_patch:  0 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by russellm):

  * needs_better_patch:  => 0
  * stage:  Unreviewed => Accepted
  * needs_tests:  => 0
  * needs_docs:  => 0

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



[Django] #12137: Postgres 8.4 imposes strict typing on CharField and TextField

2009-11-03 Thread Django
#12137: Postgres 8.4 imposes strict typing on CharField and TextField
--+-
 Reporter:  russellm  |   Owner:  nobody
   Status:  new   |   Milestone:  1.2   
Component:  Database layer (models, ORM)  | Version:  1.1   
 Keywords:|   Stage:  Unreviewed
Has_patch:  0 |  
--+-
 Consider the following model:
 {{{
 class MyObj(models.Model):
 CHOICES = (
 ('1', 'first choice')
 ('2', 'second choice')
 )
 choice = models.CharField(max_length=1, choices=CHOICES)
 }}}
 (i.e, a char field whose choices are integers, but stored as strings. Now
 run two queries. First, query using an integer:
 {{{
 MyObj.objects.filter(choice=1)
 }}}
 This yields the SQL:
 {{{
 ('SELECT `myapp_myobj`.`id`, `myapp_myobj`.`choice` FROM `myapp_myobj`
 WHERE `myapp_myobj`.`choice` = %s ', (1,))
 }}}
 Now, query with an actual string:
 {{{
 MyObj.objects.filter(choice='1')
 }}}
 which yields the SQL:
 {{{
 ('SELECT `myapp_myobj`.`id`, `myapp_myobj`.`choice` FROM `myapp_myobj`
 WHERE `myapp_myobj`.`choice` = %s ', ('1',))
 }}}
 As reported by Bill Freeman on django-users, both examples work find for
 all databases -- except for Postgres 8.4. Postgres 8.4 imposes strong type
 checking, and raises an error on the first query.

 The fact that the first example (the integer lookup) passes at all is due
 to the good grace of the databases themselves - logically, I think
 Postgres 8.4 is correct in declaring this an error. After all, "1" != 1.

 I think the fix is pretty simple. CharField doesn't currently have a
 get_db_prep_value() method, and it should.

 Compare and contrast with IntegerField or BooleanField - both these fields
 have get_db_prep_value() methods that cast the provided value to int() and
 bool(). CharField (and TextField for that matter) should do the same, but
 with unicode(). This would force the filter value of 1 into '1', which
 will be passed to the backend as a string, as it should be.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---