{"action":"created","issue":{"url":"https://api.github.com/repos/psycopg/psycopg2/issues/285","labels_url":"https://api.github.com/repos/psycopg/psycopg2/issues/285/labels{/name}","comments_url":"https://api.github.com/repos/psycopg/psycopg2/issues/285/comments","events_url":"https://api.github.com/repos/psycopg/psycopg2/issues/285/events","html_url":"https://github.com/psycopg/psycopg2/issues/285","id":56932235,"number":285,"title":"error when inserting array with only NULL values","user":{"login":"qwesda","id":384993,"avatar_url":"https://avatars.githubusercontent.com/u/384993?v=3","gravatar_id":"","url":"https://api.github.com/users/qwesda","html_url":"https://github.com/qwesda","followers_url":"https://api.github.com/users/qwesda/followers","following_url":"https://api.github.com/users/qwesda/following{/other_user}","gists_url":"https://api.github.com/users/qwesda/gists{/gist_id}","starred_url":"https://api.github.com/users/qwesda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qwesda/subscriptions","organizations_url":"https://api.github.com/users/qwesda/orgs","repos_url":"https://api.github.com/users/qwesda/repos","events_url":"https://api.github.com/users/qwesda/events{/privacy}","received_events_url":"https://api.github.com/users/qwesda/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/psycopg/psycopg2/milestones/9","html_url":"https://github.com/psycopg/psycopg2/milestones/psycopg%202.6.1","labels_url":"https://api.github.com/repos/psycopg/psycopg2/milestones/9/labels","id":991079,"number":9,"title":"psycopg 2.6.1","description":null,"creator":{"login":"dvarrazzo","id":199429,"avatar_url":"https://avatars.githubusercontent.com/u/199429?v=3","gravatar_id":"","url":"https://api.github.com/users/dvarrazzo","html_url":"https://github.com/dvarrazzo","followers_url":"https://api.github.com/users/dvarrazzo/followers","following_url":"https://api.github.com/users/dvarrazzo/following{/other_user}","gists_url":"https://api.github.com/users/dvarrazzo/gists{/gist_id}","starred_url":"https://api.github.com/users/dvarrazzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvarrazzo/subscriptions","organizations_url":"https://api.github.com/users/dvarrazzo/orgs","repos_url":"https://api.github.com/users/dvarrazzo/repos","events_url":"https://api.github.com/users/dvarrazzo/events{/privacy}","received_events_url":"https://api.github.com/users/dvarrazzo/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":10,"state":"open","created_at":"2015-02-23T10:53:53Z","updated_at":"2015-06-02T11:43:21Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-02-08T00:20:46Z","updated_at":"2015-06-02T11:43:21Z","closed_at":"2015-06-02T11:43:21Z","body":"hi,\r\n\r\nI stumbled into the following edge case: if you try to insert an array containing only `NULL` values in to a table, postgres only accepts the following syntax: `{NULL}` – but not `ARRAY[NULL]`. psycopg chooses the latter, which results in an error like `column \"array_of_int\" type integer[] but expression is of type text[]`\r\n\r\nI know that most people in their right minds would not want to insert `{NULL, NULL}`, but stranger things happen.\r\n\r\n```sql\r\nDROP TABLE IF EXISTS \"test\";\r\nDROP TYPE IF EXISTS \"test_enum\";\r\n\r\nCREATE TYPE \"test_enum\" AS ENUM('enum_val1', 'enum_val2');\r\n\r\nCREATE TABLE IF NOT EXISTS \"test\" (\r\n  \"array_of_text\" text[],\r\n  \"array_of_int\" int[],\r\n  \"array_of_bool\" boolean[],\r\n  \"array_of_enum\" \"test_enum\"[],\r\n  \r\n  \"array_array_of_text\" text[][],\r\n  \"array_array_of_int\" int[][],\r\n  \"array_array_of_bool\" boolean[][],\r\n  \"array_array_of_enum\" \"test_enum\"[][]\r\n);\r\n\r\nINSERT INTO \"test\" (\"array_of_text\") VALUES ('{NULL, NULL}'); -- succedes\r\nINSERT INTO \"test\" (\"array_of_int\") VALUES ('{NULL, NULL}'); -- succedes\r\nINSERT INTO \"test\" (\"array_of_bool\") VALUES ('{NULL, NULL}'); -- succedes\r\nINSERT INTO \"test\" (\"array_of_enum\") VALUES ('{NULL, NULL}'); -- succedes\r\n\r\nINSERT INTO \"test\" (\"array_of_text\") VALUES (ARRAY[NULL, NULL]); -- succedes\r\nINSERT INTO \"test\" (\"array_of_int\") VALUES (ARRAY[NULL, NULL]); -- failes\r\nINSERT INTO \"test\" (\"array_of_bool\") VALUES (ARRAY[NULL, NULL]);-- failes\r\nINSERT INTO \"test\" (\"array_of_enum\") VALUES (ARRAY[NULL, NULL]);-- failes\r\n\r\nINSERT INTO \"test\" (\"array_array_of_text\") VALUES ('{{NULL}, {NULL}}'); -- succedes\r\nINSERT INTO \"test\" (\"array_array_of_int\") VALUES ('{{NULL}, {NULL}}'); -- succedes\r\nINSERT INTO \"test\" (\"array_array_of_bool\") VALUES ('{{NULL}, {NULL}}'); -- succedes\r\nINSERT INTO \"test\" (\"array_array_of_enum\") VALUES ('{{NULL}, {NULL}}'); -- succedes\r\n\r\nINSERT INTO \"test\" (\"array_array_of_text\") VALUES (ARRAY[ARRAY[NULL], ARRAY[NULL]]); -- succedes\r\nINSERT INTO \"test\" (\"array_array_of_int\") VALUES (ARRAY[ARRAY[NULL], ARRAY[NULL]]); -- failes\r\nINSERT INTO \"test\" (\"array_array_of_bool\") VALUES (ARRAY[ARRAY[NULL], ARRAY[NULL]]);-- failes\r\nINSERT INTO \"test\" (\"array_array_of_enum\") VALUES (ARRAY[ARRAY[NULL], ARRAY[NULL]]);-- failes```"},"comment":{"url":"https://api.github.com/repos/psycopg/psycopg2/issues/comments/107925017","html_url":"https://github.com/psycopg/psycopg2/issues/285#issuecomment-107925017","issue_url":"https://api.github.com/repos/psycopg/psycopg2/issues/285","id":107925017,"user":{"login":"dvarrazzo","id":199429,"avatar_url":"https://avatars.githubusercontent.com/u/199429?v=3","gravatar_id":"","url":"https://api.github.com/users/dvarrazzo","html_url":"https://github.com/dvarrazzo","followers_url":"https://api.github.com/users/dvarrazzo/followers","following_url":"https://api.github.com/users/dvarrazzo/following{/other_user}","gists_url":"https://api.github.com/users/dvarrazzo/gists{/gist_id}","starred_url":"https://api.github.com/users/dvarrazzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvarrazzo/subscriptions","organizations_url":"https://api.github.com/users/dvarrazzo/orgs","repos_url":"https://api.github.com/users/dvarrazzo/repos","events_url":"https://api.github.com/users/dvarrazzo/events{/privacy}","received_events_url":"https://api.github.com/users/dvarrazzo/received_events","type":"User","site_admin":false},"created_at":"2015-06-02T11:43:20Z","updated_at":"2015-06-02T11:43:20Z","body":"Fixed for lists of None. However lists of lists of None will have to wait more (see #325)."}}