Re: [Django] #27147: Add support for defining bounds in postgres range fields

2019-06-04 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  Kirill Stepanov  |Owner:  (none)
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:  Accepted
  bounds |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by George Tantiras):

 * cc: George Tantiras (added)


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


Re: [Django] #27147: Add support for defining bounds in postgres range fields

2018-10-30 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  Kirill Stepanov  |Owner:  (none)
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:  Accepted
  bounds |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham):

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


Re: [Django] #27147: Add support for defining bounds in postgres range fields

2018-10-05 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  Kirill Stepanov  |Owner:  (none)
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:  Accepted
  bounds |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Jon Dufresne):

 * has_patch:  0 => 1


Comment:

 Thanks Jakub Skałecki for the initial code.

 [https://github.com/django/django/pull/10484 PR]

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


Re: [Django] #27147: Add support for defining bounds in postgres range fields

2018-08-01 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  Kirill Stepanov  |Owner:  (none)
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:  Accepted
  bounds |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Jakub Skałecki):

 In case anyone has this problem, I've prepared a fix. Of course better if
 appropriate fields natively supported `bounds` argument, but this is a
 drop-in replacement:

 {{{
 # db_utils.py
 from functools import partial, wraps
 from django.contrib.postgres.fields import ranges


 def create_bounded_range_field(cls):
 def init_wrapper(f):
 @wraps(f)
 def __init__(self, *args, **kwargs):
 if 'bounds' in kwargs:
 self.range_type = partial(self.range_type,
 bounds=kwargs.pop('bounds'))
 f(self, *args, **kwargs)
 return __init__
 cls.__init__ = init_wrapper(cls.__init__)
 return cls


 DateRangeField = create_bounded_range_field(ranges.DateRangeField)
 DateTimeRangeField = create_bounded_range_field(ranges.DateTimeRangeField)
 BigIntegerRangeField =
 create_bounded_range_field(ranges.BigIntegerRangeField)
 FloatRangeField = create_bounded_range_field(ranges.FloatRangeField)
 IntegerRangeField = create_bounded_range_field(ranges.IntegerRangeField)

 }}}

 Not it's possible to declare field like this:

 {{{
 from db_utils import DateRangeField

 class MyModel(Model):
 dates = DateRangeField(bounds='[]')
 }}}

 If this solution has drawbacks, let me know.

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


Re: [Django] #27147: Add support for defining bounds in postgres range fields

2018-05-30 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  Kirill Stepanov  |Owner:  (none)
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:  Accepted
  bounds |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Matthew Schinckel):

 Okay, that would not quite meet the requirements of this ticket (which
 suggest any range type should be selectable). That makes it a bit more
 complicated, but I think maybe defining a target bounds in the field
 definition is still the best approach.

 We'd want to be applying a fixed bounds to the incoming data (unless the
 widget had some way to represent the bounds types, but that's probably
 less useful for real humans to interact with), and the data fetched from
 the db should be denormalised (?) to match those bounds.

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


Re: [Django] #27147: Add support for defining bounds in postgres range fields

2018-05-30 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  Kirill Stepanov  |Owner:  (none)
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:  Accepted
  bounds |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Matthew Schinckel):

 Oh, I did this at the form field level.

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


Re: [Django] #27147: Add support for defining bounds in postgres range fields

2018-05-30 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  Kirill Stepanov  |Owner:  (none)
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:  Accepted
  bounds |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Matthew Schinckel):

 There's two parts: ensuring that the user-entered-data is upper-bounds-
 inclusive, and ensuring that the saved data is presented back to the user
 as upper-bounds-inclusive.

 The first part of this is trivial - just have a bounds value of '[]'
 passed in to the constructor. In my case, I have an InclusiveRangeMixin
 that does this in compress.

 The second part is less clear - because in the case of distinct range
 types there is a "unit value" that needs to be removed from the upper
 bounds, but in the case of continuous ranges, this is not possible (but in
 that case, postgres will not have normalised it, so it's all good).

 Anyway, code speaks louder than words here, so here's how I've approached
 this in the past:


 {{{
 class InclusiveRangeMixin(object):
 _unit_value = None

 def compress(self, values):
 range_value = super(InclusiveRangeMixin, self).compress(values)
 if range_value:
 return self.range_type(range_value.lower, range_value.upper,
 bounds='[]')

 def prepare_value(self, value):
 value = super(InclusiveRangeMixin, self).prepare_value(value)
 # We need to clean both fields.
 value = [field.clean(val) for field, val in zip(self.fields,
 value)]
 if value[1] is not None:
 value[1] = value[1] - self._unit_value
 return value


 class InclusiveDateRangeField(InclusiveRangeMixin, DateRangeField):
 _unit_value = datetime.timedelta(1)


 class InclusiveIntegerRangeField(InclusiveRangeMixin, IntegerRangeField):
 _unit_value = 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 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/065.e1fb71f13201b31d5ae7a5637621f4b1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #27147: Add support for defining bounds in postgres range fields

2016-08-29 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  impala2  |Owner:
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:  Accepted
  bounds |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by impala2):

 Replying to [comment:3 timgraham]:
 > Is this about form fields and/or model fields? How does it interact with
 the fact that for some types, "PostgreSQL always returns a range in a
 canonical form that includes the lower bound and excludes the upper bound;
 that is `[)`." as the documentation ticket says. Accepting because the
 idea seems sensible, however, I would like to see a patch to make a final
 evaluation of the idea.

 Ah, I saw that but misunderstood as "no matter how it was originally
 inserted, django will always interpret incoming data as `[)` because it
 doesn't know any better. I now see that postgres canonicalizes discrete
 ranges but I'll see what I can do about it. The proposal still at least
 makes sense for non-discrete ranges.

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


Re: [Django] #27147: Add support for defining bounds in postgres range fields

2016-08-29 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  impala2  |Owner:
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:  Accepted
  bounds |
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


Comment:

 Is this about form fields and/or model fields? How does it interact with
 the fact that for some types, "PostgreSQL always returns a range in a
 canonical form that includes the lower bound and excludes the upper bound;
 that is `[)`." as the documentation ticket says. Accepting because the
 idea seems sensible, however, I would like to see a patch to make a final
 evaluation of the idea.

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


Re: [Django] #27147: Add support for defining bounds in postgres range fields

2016-08-29 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  impala2  |Owner:
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:
  bounds |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by impala2):

 Replying to [comment:1 timgraham]:
 > Can you give a use case to demonstrate exactly how this would work? See
 also #26345.

 That ticket only refers to the documentation, not adding ability to
 override.

 My use-case is for date ranges. It's often more natural to have inclusive
 ranges (`[]`) than the default `[)`. For example it would make more sense
 that is something active for a month to start on the first and end on the
 last day of the month rather than the first of the next month, no?

 I recently converted a model from a lower/upper bound pair of date fields
 to a DateRange to take advantage of the gist index overlap exclusion but
 had to give up this natural property. I was hoping to implement the
 ability to do any type of bounds in django to bring the functionality
 back. Of course even for dates this is not always most optimal - hotel
 reservations make more sense with a `[)` range as people can check-in on
 the same day that others check out in the same room.

 Anyway that's my 2¢.

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


Re: [Django] #27147: Add support for defining bounds in postgres range fields

2016-08-29 Thread Django
#27147: Add support for defining bounds in postgres range fields
-+-
 Reporter:  impala2  |Owner:
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:  postgres range   | Triage Stage:
  bounds |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

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


Comment:

 Can you give a use case to demonstrate exactly how this would work? See
 also #26345.

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