Re: [Django] #26475: Using functools.partial in model field options causes creation of unnecessary migration on every 'makemigrations' call

2016-04-19 Thread Django
#26475: Using functools.partial in model field options causes creation of
unnecessary migration on every 'makemigrations' call
+-
 Reporter:  un-def  |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.9
 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
+-

Comment (by Tim Graham ):

 In [changeset:"799e81ef6bc8cbb944dd3594a2646a594a04b44d" 799e81e]:
 {{{
 #!CommitTicketReference repository=""
 revision="799e81ef6bc8cbb944dd3594a2646a594a04b44d"
 [1.9.x] Fixed #26475 -- Added functools.partial() support to migrations
 autodetector.

 Backport of 5402f3ab09413a571fd9d3aa27f6c76ec42ff891 from master
 }}}

--
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/064.673c4cb99bb96fb35b35b6c6b83b9967%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26475: Using functools.partial in model field options causes creation of unnecessary migration on every 'makemigrations' call

2016-04-19 Thread Django
#26475: Using functools.partial in model field options causes creation of
unnecessary migration on every 'makemigrations' call
+-
 Reporter:  un-def  |Owner:  nobody
 Type:  Bug |   Status:  closed
Component:  Migrations  |  Version:  1.9
 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 Tim Graham ):

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


Comment:

 In [changeset:"5402f3ab09413a571fd9d3aa27f6c76ec42ff891" 5402f3ab]:
 {{{
 #!CommitTicketReference repository=""
 revision="5402f3ab09413a571fd9d3aa27f6c76ec42ff891"
 Fixed #26475 -- Added functools.partial() support to migrations
 autodetector.
 }}}

--
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/064.1837e6808b4dff9aac501bdf1e9aedf7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26475: Using functools.partial in model field options causes creation of unnecessary migration on every 'makemigrations' call

2016-04-19 Thread Django
#26475: Using functools.partial in model field options causes creation of
unnecessary migration on every 'makemigrations' call
+-
 Reporter:  un-def  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  1.9
 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 timgraham):

 * needs_better_patch:  1 => 0
 * stage:  Accepted => Ready for checkin
 * needs_docs:  1 => 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 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/064.7f73c766d8203e91118fdd9a3c031d44%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26475: Using functools.partial in model field options causes creation of unnecessary migration on every 'makemigrations' call

2016-04-18 Thread Django
#26475: Using functools.partial in model field options causes creation of
unnecessary migration on every 'makemigrations' call
+
 Reporter:  un-def  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  1.9
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  1   |  Needs documentation:  1
  Needs tests:  0   |  Patch needs improvement:  1
Easy pickings:  0   |UI/UX:  0
+

Comment (by schinckel):

 I've created a PR for this issue:
 https://github.com/django/django/pull/6470

--
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/064.7ab835083fa6e7b4d45e78bc32b4f7a2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26475: Using functools.partial in model field options causes creation of unnecessary migration on every 'makemigrations' call

2016-04-18 Thread Django
#26475: Using functools.partial in model field options causes creation of
unnecessary migration on every 'makemigrations' call
+
 Reporter:  un-def  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  1.9
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Accepted
Has patch:  1   |  Needs documentation:  1
  Needs tests:  0   |  Patch needs improvement:  1
Easy pickings:  0   |UI/UX:  0
+
Changes (by MarkusH):

 * needs_better_patch:  0 => 1
 * has_patch:  0 => 1
 * needs_docs:  0 => 1


Comment:

 Tim, I think we should backport this to 1.9, given the half-implemented
 partial support in #25185.

--
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/064.c746e40d8c996b1db6bb0a9150a80e35%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26475: Using functools.partial in model field options causes creation of unnecessary migration on every 'makemigrations' call

2016-04-12 Thread Django
#26475: Using functools.partial in model field options causes creation of
unnecessary migration on every 'makemigrations' call
+
 Reporter:  un-def  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  1.9
 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 timgraham):

 * stage:  Unreviewed => Accepted


--
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/064.2676f83bd6e3d85539de863e0f130cb5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26475: Using functools.partial in model field options causes creation of unnecessary migration on every 'makemigrations' call

2016-04-08 Thread Django
#26475: Using functools.partial in model field options causes creation of
unnecessary migration on every 'makemigrations' call
+--
 Reporter:  un-def  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  1.9
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by timgraham):

 * cc: MarkusH (added)


Comment:

 I guess it was a mistake to add serialization support for
 `functools.partial` in #25185 when the rest of the migration process
 doesn't totally work. Perhaps we should revert that in favor of a wrapper
 class similar to what's suggested above and that also has a
 `deconstruct()` method?

--
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/064.e6530f2b7bf4977dcaf85d2ad5c37746%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #26475: Using functools.partial in model field options causes creation of unnecessary migration on every 'makemigrations' call

2016-04-07 Thread Django
#26475: Using functools.partial in model field options causes creation of
unnecessary migration on every 'makemigrations' call
+--
 Reporter:  un-def  |Owner:  nobody
 Type:  Bug |   Status:  new
Component:  Migrations  |  Version:  1.9
 Severity:  Normal  |   Resolution:
 Keywords:  | Triage Stage:  Unreviewed
Has patch:  0   |  Needs documentation:  0
  Needs tests:  0   |  Patch needs improvement:  0
Easy pickings:  0   |UI/UX:  0
+--
Changes (by oneTimePad):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 partial is not a python class to subclass; it's a function: see
 [implementation]
 :https://github.com/python/cpython/blob/master/Lib/functools.py#236


 Maybe:

 {{{
 class Partial(object):

  def __init__(self,partialFct):
   self.func = partialFct
  def __call__(self,*args,**kwargs):
  return self.func(*args,**kwargs)

  def __eq__(self,other):
  return(  self.func.func == other.func.func and
self.func.args == other.func.args and
self.func.keywords == other.func.keywords)
  def __ne__(self,other):
   return not self.__eq__(other)

 Usage:
  def concat(*args):
return ''.join(args)

 class TestModel(models.Model):
   test_field = models.CharField(max_length =128, default =
 Partial(partial(concat, 'foo', 'bar')))


 }}}

 Just an idea. Not tested with Django.

--
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/064.0b685d28a0cc7055643813197a7579f3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #26475: Using functools.partial in model field options causes creation of unnecessary migration on every 'makemigrations' call

2016-04-07 Thread Django
#26475: Using functools.partial in model field options causes creation of
unnecessary migration on every 'makemigrations' call
+
 Reporter:  un-def  |  Owner:  nobody
 Type:  Bug | Status:  new
Component:  Migrations  |Version:  1.9
 Severity:  Normal  |   Keywords:
 Triage Stage:  Unreviewed  |  Has patch:  0
Easy pickings:  0   |  UI/UX:  0
+
 Consider this simple model:


 {{{
 from django.db import models

 from functools import partial


 def concat(*args):
 return ''.join(args)


 class TestModel(models.Model):

 test_field = models.CharField(
 max_length=128,
 default=partial(concat, 'foo', 'bar')
 )
 }}}

 Every time you run `./manage.py makemigration` it leads to creation of
 migration:

 {{{
 $ ./manage.py makemigrations
 Migrations for 'test_app':
   0008_auto_py:
 - Alter field test_field on testmodel

 $ ./manage.py makemigrations
 Migrations for 'test_app':
   0009_auto_py:
 - Alter field test_field on testmodel

 $ ./manage.py makemigrations
 Migrations for 'test_app':
   0010_auto_py:
 - Alter field test_field on testmodel
 }}}

 All created migrations are equal.

 Cause: when project state is rendered from previous migration file,
 `functools.partial` instance is created (`migrations.AlterField(...
 default=functools.partial(djtest_app.models.concat, *('foo', 'bar'),
 **{}), ...)`). After that each model field is deconstructed to dict and
 previous and current field states (i.e. dicts) are compared
 
[https://github.com/django/django/blob/2cd2d188516475ddf256e6267cd82c495fb5c430/django/db/migrations/autodetector.py#L862]
 But different instances of `functools.partial` with same arguments are not
 equal — I guess that `partial` doesn't implement own `__eq__`/`__ne__`
 methods, so comparison is made by object `id()` (memory address), and
 false field changes is detected.

 Possible solution (workaround): we can use own `partial` subclass in
 migration files. Our subclass implements custom `__eq__`/`__ne__` magic
 methods:

 {{{
 class Partial(functools.partial):

 def __eq__(self, other):
 return (self.func == other.func and
 self.args == other.args and
 self.keywords == other.keywords)

 def __ne__(self, other):
 return not self.__eq__(other)
 }}}

--
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/049.e7f481edc0f24e40c3bb0c2baf100b50%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.