Closed timvandam closed 5 months ago
Closing for now since this seems to have fixed itself
Technically, it is possible that an array would contain null values:
CREATE TEMP TABLE example_table (
id SERIAL PRIMARY KEY,
array_column TEXT[]
);
INSERT INTO example_table (array_column) VALUES
('{"element1", NULL, "element3"}'),
('{"element4", "element5", NULL}'),
(NULL);
select * from example_table;
maybe I should add a strict.*
options
In your table you do not have a NOT NULL on array_column. If I add that the insert fails
Oh you're right... my bad
Oh wait, I wasn't wrong:
DROP TABLE IF EXISTS example_table;
CREATE TEMP TABLE example_table (
id SERIAL PRIMARY KEY,
array_column TEXT[] NOT NULL
);
INSERT INTO example_table (array_column) VALUES
('{"element1", NULL, "element3"}'),
('{"element4", "element5", NULL}');
select * from example_table;
A I see what you mean now, but then the type would is still wrong. I got roles: string[] | null
instead of roles: (string | null)[]
. However I'm getting string[]
now
Yeah, the original issue was probably due to a caching issue, restarting ESLint would fix that.
In any case, As I wrote previously, I might consider adding strict flags, or change the behavior with a major version
Describe the bug A clear and concise description of what the bug is.
When selecting an array column (eg VARCHAR(255)[]) the inferred type is nullable, even when the column is non nullable.
To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
It should yield
roles: string[]
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.
I've checked whether postgres can somehow return NULL here, but it seems not. Inserting NULL is also not possible, i.e.
fails