Re: [Django] #24709: ArrayField doesn't support .update() and F() objects

2019-11-22 Thread Django
#24709: ArrayField doesn't support .update() and F() objects
-+-
 Reporter:  ris  |Owner:  nobody
 Type:  New feature  |   Status:  closed
Component:  contrib.postgres |  Version:  1.8
 Severity:  Normal   |   Resolution:  duplicate
 Keywords:  postgresql contrib   | Triage Stage:  Accepted
  arrayfield update  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Baptiste Mispelon):

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


Comment:

 Duplicate of #26355

 (even though this ticket is older, the other one has a pull request which
 is why I'm closing this one)

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/061.e5809bf5878c58581356176bb12c2bfd%40djangoproject.com.


Re: [Django] #24709: ArrayField doesn't support .update() and F() objects

2017-05-03 Thread Django
#24709: ArrayField doesn't support .update() and F() objects
-+-
 Reporter:  ris  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  1.8
 Severity:  Normal   |   Resolution:
 Keywords:  postgresql contrib   | Triage Stage:  Accepted
  arrayfield update  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Frederik Creemers):

 I'm not that familiar with the internals, so I don't know if my use case
 helps flesh out ideas for how to implement this, but here's what I have:

 I have a score_weights list, which is an array of floating point
 numbers.Every User has a "scores" field, containing an array with the same
 number of items. I'd like to sort users by a weighted sum of these scores,
 with the weights coming from this score_weights list. In other words, the
 users are ordered by the dot product of their scores array and the
 score_weights array.


 {{{
 order_expression = -1 * sum([
 F("scores__%s" % i) * score_weights[i]
 for i in xrange(len(crit.score_weights))
 ])
 }}}

 Currently, this raises this error:

 {{{
 Traceback (most recent call last):
   File "", line 1, in 
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/query.py", line 256, in __iter__
 self._fetch_all()
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/query.py", line 1087, in _fetch_all
 self._result_cache = list(self.iterator())
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/query.py", line 54, in __iter__
 results = compiler.execute_sql()
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/sql/compiler.py", line 824, in execute_sql
 sql, params = self.as_sql()
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/sql/compiler.py", line 369, in as_sql
 extra_select, order_by, group_by = self.pre_sql_setup()
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/sql/compiler.py", line 47, in
 pre_sql_setup
 order_by = self.get_order_by()
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/sql/compiler.py", line 308, in
 get_order_by
 self.query, allow_joins=True, reuse=None)
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/expressions.py", line 209, in
 resolve_expression
 for expr in c.get_source_expressions()
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/expressions.py", line 404, in
 resolve_expression
 c.rhs = c.rhs.resolve_expression(query, allow_joins, reuse, summarize,
 for_save)
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/expressions.py", line 403, in
 resolve_expression
 c.lhs = c.lhs.resolve_expression(query, allow_joins, reuse, summarize,
 for_save)
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/expressions.py", line 403, in
 resolve_expression
 c.lhs = c.lhs.resolve_expression(query, allow_joins, reuse, summarize,
 for_save)
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/expressions.py", line 403, in
 resolve_expression
 c.lhs = c.lhs.resolve_expression(query, allow_joins, reuse, summarize,
 for_save)
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/expressions.py", line 403, in
 resolve_expression
 c.lhs = c.lhs.resolve_expression(query, allow_joins, reuse, summarize,
 for_save)
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/expressions.py", line 404, in
 resolve_expression
 c.rhs = c.rhs.resolve_expression(query, allow_joins, reuse, summarize,
 for_save)
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/expressions.py", line 403, in
 resolve_expression
 c.lhs = c.lhs.resolve_expression(query, allow_joins, reuse, summarize,
 for_save)
   File "/Users/frederikcreemers/.virtualenvs/employebla/lib/python2.7
 /site-packages/django/db/models/expressions.py", line 463, in
 resolve_expression
 return query.resolve_ref(self.name, allow_joins, 

Re: [Django] #24709: ArrayField doesn't support .update() and F() objects

2016-04-07 Thread Django
#24709: ArrayField doesn't support .update() and F() objects
-+-
 Reporter:  ris  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  1.8
 Severity:  Normal   |   Resolution:
 Keywords:  postgresql contrib   | Triage Stage:  Accepted
  arrayfield update  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by codingjoe):

 * cc: info@… (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/061.6e4670959c8572eb46766e046b038014%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24709: ArrayField doesn't support .update() and F() objects

2015-05-26 Thread Django
#24709: ArrayField doesn't support .update() and F() objects
-+-
 Reporter:  ris  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  1.8
 Severity:  Normal   |   Resolution:
 Keywords:  postgresql contrib   | Triage Stage:  Accepted
  arrayfield update  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by jarshwah):

 This seems like a very similar problem to how F() and Sum() evolved
 separately when they could have been the same with a little (lot..) more
 work. Marc, could you require that the inputs to Array/HStore be
 expressions (with an appropriate _parse_expression() to wrap basic values
 in Value())? If you provide support for expressions only, then getting
 basic values in comes fairly naturally too.

 I haven't looked into the implementation of these fields though, so I
 don't know how feasible it would be to support.

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


Re: [Django] #24709: ArrayField doesn't support .update() and F() objects

2015-05-26 Thread Django
#24709: ArrayField doesn't support .update() and F() objects
-+-
 Reporter:  ris  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  1.8
 Severity:  Normal   |   Resolution:
 Keywords:  postgresql contrib   | Triage Stage:  Accepted
  arrayfield update  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by adamchainz):

 I have written a similar separate F API for the the comma-separated fields
 in Django-MySQL - see http://django-
 mysql.readthedocs.org/en/latest/model_fields.html#listf-expressions . I
 made a `ListF` class for doing single atomic add/remove operations on
 either end of the list, which is about all that can be done with MySQL's
 comma-separated-list parsing capabilities.

 It is obviously much less involved than Postgres' arrays, but maybe it
 will inspire. I think add/remove operations are quite useful to consider
 on top of the 'set element at position X to Y' and 'set array field to
 [Y]' operations.

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


Re: [Django] #24709: ArrayField doesn't support .update() and F() objects

2015-05-01 Thread Django
#24709: ArrayField doesn't support .update() and F() objects
-+-
 Reporter:  ris  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  1.8
 Severity:  Normal   |   Resolution:
 Keywords:  postgresql contrib   | Triage Stage:  Accepted
  arrayfield update  |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by mjtamlyn):

 The silent coercion to string is normal behaviour for Django actually in
 many cases - we actually would like `ModelA.objects.update(name_array=[1,
 2])` to work (as it would if it were a `CharField`.

 Supporting F objects like that is a very nice idea, but I'm not sure how
 possible it is. If we do implement it, it should work for Hstore and Json
 as well. In these cases there are more complex options - for example you
 can update just a single key of the Hstore without affecting the rest,
 which would be a very useful addition.

 A simpler option could be to have a distinct API for it - something like
 `ModelA.objects.update(name_array=FArray(0, F(name))` which would generate
 an update statement like `UPDATE app_modela SET name_array[0]=F(name)`.
 This API could also be a bit clever, and also support
 `ModelA.objects.update(name_array=FArray([F('name')]))`. We would then
 have similar FJSON and FHstore objects. I'm pretty sure these could be
 supported without changes to the core ORM by making them look sufficiently
 like F objects.

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


Re: [Django] #24709: ArrayField doesn't support .update() and F() objects (was: New contrib.postgres ArrayField doesn't work quite as expected with .update () and F() objects)

2015-04-27 Thread Django
#24709: ArrayField doesn't support .update() and F() objects
-+-
 Reporter:  ris  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  contrib.postgres |  Version:  1.8
 Severity:  Normal   |   Resolution:
 Keywords:  postgresql contrib   | Triage Stage:  Accepted
  arrayfield update  |
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
 * component:  Database layer (models, ORM) => contrib.postgres
 * needs_tests:   => 0
 * needs_docs:   => 0
 * type:  Bug => New feature
 * stage:  Unreviewed => Accepted


Comment:

 I am not sure that F expressions can be supported like that, but if not,
 it might be worth documenting the restriction and/or throwing a better
 error message rather than silently coercing to string.

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