{"action":"opened","issue":{"url":"https://api.github.com/repos/npgsql/npgsql/issues/1271","repository_url":"https://api.github.com/repos/npgsql/npgsql","labels_url":"https://api.github.com/repos/npgsql/npgsql/issues/1271/labels{/name}","comments_url":"https://api.github.com/repos/npgsql/npgsql/issues/1271/comments","events_url":"https://api.github.com/repos/npgsql/npgsql/issues/1271/events","html_url":"https://github.com/npgsql/npgsql/issues/1271","id":175782138,"number":1271,"title":"InvalidCastException in GetFieldValue with empty multi-dimensional array","user":{"login":"lsedlacek","id":14178046,"avatar_url":"https://avatars.githubusercontent.com/u/14178046?v=3","gravatar_id":"","url":"https://api.github.com/users/lsedlacek","html_url":"https://github.com/lsedlacek","followers_url":"https://api.github.com/users/lsedlacek/followers","following_url":"https://api.github.com/users/lsedlacek/following{/other_user}","gists_url":"https://api.github.com/users/lsedlacek/gists{/gist_id}","starred_url":"https://api.github.com/users/lsedlacek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsedlacek/subscriptions","organizations_url":"https://api.github.com/users/lsedlacek/orgs","repos_url":"https://api.github.com/users/lsedlacek/repos","events_url":"https://api.github.com/users/lsedlacek/events{/privacy}","received_events_url":"https://api.github.com/users/lsedlacek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-08T15:17:58Z","updated_at":"2016-09-08T15:17:58Z","closed_at":null,"body":"Running the code below expectedly prints 'foobar':\r\n\r\n    var conn = new NpgsqlConnection(DatabaseConfig.ConnectionString);\r\n    conn.Open();\r\n\r\n    new NpgsqlCommand(@\"CREATE TABLE test (arr TEXT[]);\", conn)\r\n        .ExecuteNonQuery();\r\n\r\n    var arr = new[,] { { \"foo\", \"bar\" } };\r\n\r\n    var insCmd = new NpgsqlCommand(@\"INSERT INTO test(arr) VALUES(:arr);\", conn);\r\n    insCmd.Parameters.AddWithValue(\"arr\", arr);\r\n    insCmd.ExecuteNonQuery();\r\n\r\n    var reader = new NpgsqlCommand(@\"SELECT arr FROM test;\", conn).ExecuteReader();\r\n    reader.Read();\r\n\r\n    Console.Write(reader.GetFieldValue<string[,]>(0)[0, 0]);\r\n    Console.Write(reader.GetFieldValue<string[,]>(0)[0, 1]);\r\n\r\nRunning the same code with arr = new string[0,0] throws the following expection:\r\n\r\n    System.InvalidCastException : Unable to cast object of type 'System.String[]' to type 'System.String[,]'.\r\n       at Npgsql.NpgsqlDataReader.GetFieldValueInternal[T](Int32 ordinal)\r\n       at Tests.Npgsql.ReadSingle_WithEmptyMultidimensionalArray_ReturnsEmptyArray() in C:\\dev\\tmp\\Tests\\Npgsql.cs:line 100"}}
{"actor":{"display_login":"lsedlacek"}}