>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.
Indeed, thanks for sharing that Jörg!

Just to be sure, on postgresql I have,
psql> select version();
PostgreSQL 12.11 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 7.3.1
20180712 (Red Hat 7.3.1-12), 64-bit

psql>select (array[array[NULL,NULL]]);
{{NULL,NULL}}

psql>select array['{NULL, NULL}'] ;
{"{NULL, NULL}"}

The third is correct, but not the generated query I'd expect when writing
`nested_field=[[None, None]]` in the ORM.
(It outputs what I'd expect from `nested_field=["{NULL, NULL}"]`).

I wonder whether this bug could not be fixed in django by generating the
additional "array" in nested fields,
(I did not yet figure out how the additional array is generated when at
least one non NULL field is put there, it is in my todos :)).
WDYT?






Le lun. 10 oct. 2022 à 11:15, Jörg Breitbart <j.breitb...@netzkolchose.de>
a écrit :

> 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 a topic in the
> Google Groups "Django developers  (Contributions to Django itself)" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-developers/4OvbN0EUUsM/unsubscribe
> .
> To unsubscribe from this group and all its topics, 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
> .
>


-- 
[image: img] <https://signitic.app/linkc/L3B5SXlwV0U-L3A4PQ>


*Ion Alberdi*


[image: img] <https://signitic.app/linkc/L3B5SXlwV0U-L1pzPQ> [image: img]
<https://signitic.app/linkc/L3B5SXlwV0U-L3A4PQ> [image: img]
<https://signitic.app/linkc/L3B5SXlwV0U-L1pRPQ> [image: img]
<https://signitic.app/linkc/L3B5SXlwV0U-L1pnPQ> [image: img]
<https://signitic.app/linkc/L3B5SXlwV0U-L1prPQ>

-- 
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/CANbgw4Bo5bWhuzgLrbT4jp%2B-T93_QMMQKe-1wjF57bMokM21tQ%40mail.gmail.com.
  • 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