Not sure if it is related, but the last sentence here caught my attention:

> I wonder whether this is due to django or psycopg2. Indeed, the bug is
> not reproduced
> if at least one of the element in the nested array is not null.


When doing a COPY FROM replacement of bulk_update for postgres I stumbled over several weird edge cases of nested arrays and its NULL behavior - documented here https://github.com/netzkolchose/django-fast-update/blob/59b0e6fa6affdcf8c66b2edee2e1bf1b926f4180/fast_update/copy.py#L566

This seems to be a postgres internal thing and how they implemented ARRAY, as it is reproducible in pgsql as well. Imho the important bit is, that ARRAY will drop the top level array to {} (empty array with no dimension info), if there is at least one empty sub array declared with ARRAY among NULLs, while if all sub entries are NULL the top level array will still manifest with dimension info, but now with entries set to NULL. Thats a quite weird behavior imho.


Am 09.10.22 um 12:49 schrieb Ion Alberdi:
Hello to all,

a unit test added at
https://github.com/pricemoov/django/pull/2
shows that the exact filter on a full "NULL nested array" currently fails.
(the commit messages shows how to reproduce the error).

More precisely, the error is
"django.db.utils.DataError: invalid input syntax for type integer: "{NULL,NULL}"

    LINE 1: ...ullableintegerarraymodel"."field_nested" = (ARRAY['{NULL,NUL..."

and seems to be due to the query being generated as "...ARRAY['{NULL,NULL}']..."
instead of "...ARRAY[ARRAY[NULL,NULL]]..."

I wonder whether this is due to django or psycopg2. Indeed, the bug is not reproduced
if at least one of the element in the nested array is not null.

Is the bug worth creating a ticket?


Best regards,

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com <mailto:django-developers+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/bad3435e-1299-4b1d-b701-7881e111ec90n%40googlegroups.com <https://groups.google.com/d/msgid/django-developers/bad3435e-1299-4b1d-b701-7881e111ec90n%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
netzkolchose.de UG (haftungsbeschränkt)
Geschäftsführer: Jörg Breitbart
Handelsregister: HRB 504791 Amtsgericht Jena
Steuer-Nr.: 161/115/07450
USt-IdNr.: DE268234065

--
You received this message because you are subscribed to the Google Groups "Django 
developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/ca23d835-08cc-1c7a-323c-faa552560ef6%40netzkolchose.de.
  • Arr... Ion Alberdi
    • ... 'Adam Johnson' via Django developers (Contributions to Django itself)
      • ... Ion Alberdi
        • ... 'Adam Johnson' via Django developers (Contributions to Django itself)
          • ... Ion Alberdi
    • ... Jörg Breitbart
      • ... Ion Alberdi
        • ... Jörg Breitbart
          • ... Ion Alberdi
            • ... Ion Alberdi

Reply via email to