The docs say that arrays don't contain SQL nulls. This appears to be true
_within_ the array. Selecting an element beyond the end of the array,
however, does return null and generates no error.
Is the ability to query an array element beyond the end documented somewhere
as legal and is this behavior likely to continue?
This behavior works well for me but I don't want to build an app around it
unless I know it is legal and not just an accidental discovery. My tests:
The data:
steve=# select * from foo;
id | bar
----+-----------------
1 | {one}
2 | {one,two}
3 | {one,two,three}
4 | {"","",""}
(4 rows)
Looking for nulls:
steve=# select id, case when bar[3] is null then 'I am null' else bar[3] end
as bar3 from foo;
id | bar3
----+-----------
1 | I am null
2 | I am null
3 | three
4 |
(4 rows)
Cheers,
Steve
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера