Re: [Django] #28431: default='' (non-bytestring) on BinaryField crashes some migration operations

2019-03-25 Thread Django
#28431: default='' (non-bytestring) on BinaryField crashes some migration
operations
-+-
 Reporter:  James|Owner:  Hasan
 |  Ramezani
 Type:  Bug  |   Status:  closed
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

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


Comment:

 In [changeset:"981dd6dd71ea80e5149c2eff564622e96c12b5be" 981dd6dd]:
 {{{
 #!CommitTicketReference repository=""
 revision="981dd6dd71ea80e5149c2eff564622e96c12b5be"
 Fixed #28431 -- Added a system check for BinaryField to prevent strings
 defaults.

 Thanks Claude Paroz for the initial patch.
 }}}

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.e634aaea120fad9904f44956d56adac1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28431: default='' (non-bytestring) on BinaryField crashes some migration operations

2019-03-25 Thread Django
#28431: default='' (non-bytestring) on BinaryField crashes some migration
operations
-+-
 Reporter:  James|Owner:  Hasan
 |  Ramezani
 Type:  Bug  |   Status:  assigned
Component:  Core (System |  Version:  master
  checks)|
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * version:  1.10 => master
 * component:  Migrations => Core (System checks)
 * stage:  Accepted => Ready for checkin


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.a66d58cc4fe3a5be6ecdeb98b58fbec5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28431: default='' (non-bytestring) on BinaryField crashes some migration operations

2019-03-18 Thread Django
#28431: default='' (non-bytestring) on BinaryField crashes some migration
operations
+--
 Reporter:  James   |Owner:  Hasan Ramezani
 Type:  Bug |   Status:  assigned
Component:  Migrations  |  Version:  1.10
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  1   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by Hasan Ramezani):

 * owner:  Windson yang => Hasan Ramezani
 * has_patch:  0 => 1


Comment:

 System check for preventing default string value for BinaryField added
 based on @Claude Paroz suggestion

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.d765234afe4027537d76c8ba325018ab%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28431: default='' (non-bytestring) on BinaryField crashes some migration operations

2017-10-22 Thread Django
#28431: default='' (non-bytestring) on BinaryField crashes some migration
operations
+
 Reporter:  James   |Owner:  Windson yang
 Type:  Bug |   Status:  assigned
Component:  Migrations  |  Version:  1.10
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+

Comment (by Claude Paroz):

 I would also suggest a system check to prevent default strings in the
 first place. Something like:
 {{{
 diff --git a/django/db/models/fields/__init__.py
 b/django/db/models/fields/__init__.py
 index b2e9b18351..af4671c0f6 100644
 --- a/django/db/models/fields/__init__.py
 +++ b/django/db/models/fields/__init__.py
 @@ -2292,6 +2292,22 @@ class BinaryField(Field):
  if self.max_length is not None:
 self.validators.append(validators.MaxLengthValidator(self.max_length))

 +def check(self, **kwargs):
 +errors = super().check(**kwargs)
 +errors.extend(self._check_default_is_not_str(**kwargs))
 +return errors
 +
 +def _check_default_is_not_str(self, **kwargs):
 +if self.has_default() and isinstance(self.default, str):
 +return [
 +checks.Error(
 +"BinaryField 'default' cannot be a string, use bytes
 content instead.",
 +obj=self,
 +id='fields.E170',
 +)
 +]
 +return []
 +
  def deconstruct(self):
  name, path, args, kwargs = super().deconstruct()
  del kwargs['editable']
 }}}

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.96417e57c7e70780ad809077d7db5802%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28431: default='' (non-bytestring) on BinaryField crashes some migration operations

2017-08-08 Thread Django
#28431: default='' (non-bytestring) on BinaryField crashes some migration
operations
+
 Reporter:  James   |Owner:  Windson yang
 Type:  Bug |   Status:  assigned
Component:  Migrations  |  Version:  1.10
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+

Comment (by Windson yang):

 It didn't crash when I using sqlite3, maybe related to Postgres, right?

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.513cb108583fed8bfa6c9aa5152cc481%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28431: default='' (non-bytestring) on BinaryField crashes some migration operations

2017-08-08 Thread Django
#28431: default='' (non-bytestring) on BinaryField crashes some migration
operations
+
 Reporter:  James   |Owner:  Windson yang
 Type:  Bug |   Status:  assigned
Component:  Migrations  |  Version:  1.10
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+
Changes (by Windson yang):

 * owner:  nobody => Windson yang
 * status:  new => assigned


-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.dff16bcd59ab68cc3dc1161f3d958900%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28431: default='' (non-bytestring) on BinaryField crashes some migration operations (was: Default value for BinaryField in reverse migration)

2017-07-24 Thread Django
#28431: default='' (non-bytestring) on BinaryField crashes some migration
operations
+
 Reporter:  James   |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  1.10
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+
Changes (by Tim Graham):

 * stage:  Unreviewed => Accepted


Comment:

 While doing a quick test, I noticed that a non-bytestring also crashes
 with `AddField` (forward). I'm not sure about the proper resolution
 (perhaps a system check error for an invalid default?) but the
 inconsistency is certainly unexpected.

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.5bc6cbaee87e249bc72258a6c23cbc06%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.