Changes between Initial Version and Version 1 of Ticket #26355, comment 3


Ignore:
Timestamp:
Mar 16, 2016, 9:58:52 AM (9 years ago)
Author:
Nick Pope

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26355, comment 3

    initial v1  
    5656Python: Item.objects.update(value__1_1=[4, 5, 6])  # would need different syntax?
    5757SQL:    UPDATE item SET value = value[array_lower(value, 1):1]
    58             || ARRAY[4, 5, 6] || value[3:array_upper(value, 1)];
    59 Result: [1, 4, 5, 6, 3]
     58            || ARRAY[4, 5, 6] || value[2:array_upper(value, 1)];
     59Result: [1, 4, 5, 6, 2, 3]
    6060}}}
     61
     62Note that updating a slice with more or less values that the width of the slice will require the same approach as the above example because PostgreSQL silently drops excess values provided and `ERROR:  source array too small` is thrown if there are not enough values.
    6163
    6264Another consideration is for the `array_prepend` function, but I'm not sure how that could be handled nicely in the expressions syntax.
Back to Top