{"action":"created","issue":{"url":"https://api.github.com/repos/jakob/Postico/issues/30","labels_url":"https://api.github.com/repos/jakob/Postico/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/jakob/Postico/issues/30/comments","events_url":"https://api.github.com/repos/jakob/Postico/issues/30/events","html_url":"https://github.com/jakob/Postico/issues/30","id":94832080,"number":30,"title":"Internal Error when adding CHECK constraint with nonexistent column name","user":{"login":"ndmeiri","id":8139148,"avatar_url":"https://avatars.githubusercontent.com/u/8139148?v=3","gravatar_id":"","url":"https://api.github.com/users/ndmeiri","html_url":"https://github.com/ndmeiri","followers_url":"https://api.github.com/users/ndmeiri/followers","following_url":"https://api.github.com/users/ndmeiri/following{/other_user}","gists_url":"https://api.github.com/users/ndmeiri/gists{/gist_id}","starred_url":"https://api.github.com/users/ndmeiri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndmeiri/subscriptions","organizations_url":"https://api.github.com/users/ndmeiri/orgs","repos_url":"https://api.github.com/users/ndmeiri/repos","events_url":"https://api.github.com/users/ndmeiri/events{/privacy}","received_events_url":"https://api.github.com/users/ndmeiri/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-13T23:11:59Z","updated_at":"2015-07-14T18:45:41Z","closed_at":null,"body":"Postico will encounter an \"Internal Error\" when a user tries to add a `CHECK` constraint to a column if the column name in the expression does not exist in the table. For example, I have a table with 12 columns:\r\n`id, start_date, ..., worker_count, ...`\r\nI tired to add a `CHECK ` constraint to the `worker_count` column by clicking the \"+\" button, selecting \"Check...\", and entering the expression `workers_count >= 0`. Note that the `worker_count` column is of type `smallint`.\r\n\r\nFrom the looks of the error (see below), some type of loop isn't stopped before going beyond the bounds of the mutable array that holds the column names. Normally, this is fine because a `CHECK` constraint expression should only involve existing column names. But, evidently, this throws an exception when the column name is nonexistent.\r\n\r\nAlso, when I restart Postico after the crash, I can't go back into my table to correct the constant expression. Whenever I try to open the structure of that table, I get a similar \"Internal Error\" alert. If I choose the \"Continue\" option in the alert, I just see a blank view. Do you have any temporary workaround ideas for fixing that constraint expression until the issue is fixed?\r\n\r\nI encountered the error in v0.24 and was able to reproduce it in v0.25 also.\r\n\r\nSee below for the error message and stack trace generated by Postico before crashing:\r\n```\r\nException Name: NSRangeException\r\nDescription: *** -[__NSArrayM objectAtIndex:]: index 9223372036854775807 beyond bounds [0 .. 11]\r\nUser Info: (null)\r\n\r\n0   CoreFoundation                      0x00007fff964d3b5c __exceptionPreprocess + 172\r\n1   libobjc.A.dylib                     0x00007fff86fa08e8 objc_exception_throw + 48\r\n2   CoreFoundation                      0x00007fff96392c65 -[__NSArrayM objectAtIndex:] + 245\r\n3   Postico                             0x000000010b78d03c Postico + 307260\r\n4   CoreFoundation                      0x00007fff9648c64c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12\r\n5   CoreFoundation                      0x00007fff9648c5bf ___CFXRegistrationPost_block_invoke + 63\r\n6   CoreFoundation                      0x00007fff9648bc87 _CFXRegistrationPost + 407\r\n7   CoreFoundation                      0x00007fff9648b9f2 ___CFXNotificationPost_block_invoke + 50\r\n8   CoreFoundation                      0x00007fff96487e92 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1938\r\n9   CoreFoundation                      0x00007fff96375293 _CFXNotificationPost + 675\r\n10  Foundation                          0x00007fff89ae5bdd -[NSNotificationCenter postNotificationName:object:userInfo:] + 66\r\n11  Postico                             0x000000010b80a38e Postico + 820110\r\n12  CoreFoundation                      0x00007fff9648c64c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12\r\n13  CoreFoundation                      0x00007fff9648c5bf ___CFXRegistrationPost_block_invoke + 63\r\n14  CoreFoundation                      0x00007fff9648bc87 _CFXRegistrationPost + 407\r\n15  CoreFoundation                      0x00007fff9648b9f2 ___CFXNotificationPost_block_invoke + 50\r\n16  CoreFoundation                      0x00007fff96487e92 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1938\r\n17  CoreFoundation                      0x00007fff96375293 _CFXNotificationPost + 675\r\n18  Postico                             0x000000010b77d43a Postico + 242746\r\n19  libdispatch.dylib                   0x00007fff8bcb5c5b _dispatch_call_block_and_release + 12\r\n20  libdispatch.dylib                   0x00007fff8bcb1c11 _dispatch_client_callout + 8\r\n21  libdispatch.dylib                   0x00007fff8bcc44ea _dispatch_after_timer_callback + 77\r\n22  libdispatch.dylib                   0x00007fff8bcb1c11 _dispatch_client_callout + 8\r\n23  libdispatch.dylib                   0x00007fff8bcbf53e _dispatch_source_latch_and_call + 2227\r\n24  libdispatch.dylib                   0x00007fff8bcb6f5f _dispatch_source_invoke + 577\r\n25  libdispatch.dylib                   0x00007fff8bcc2aed _dispatch_main_queue_callback_4CF + 414\r\n26  CoreFoundation                      0x00007fff9641ac19 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9\r\n27  CoreFoundation                      0x00007fff963d57cd __CFRunLoopRun + 1949\r\n28  CoreFoundation                      0x00007fff963d4dc8 CFRunLoopRunSpecific + 296\r\n29  HIToolbox                           0x00007fff8d679a59 RunCurrentEventLoopInMode + 235\r\n30  HIToolbox                           0x00007fff8d6797ef ReceiveNextEventCommon + 432\r\n31  HIToolbox                           0x00007fff8d67962f _BlockUntilNextEventMatchingListInModeWithFilter + 71\r\n32  AppKit                              0x00007fff8bde679c _DPSNextEvent + 945\r\n33  AppKit                              0x00007fff8c1b45c9 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 343\r\n34  AppKit                              0x00007fff8bddc6dc -[NSApplication run] + 682\r\n35  AppKit                              0x00007fff8bd5eb6d NSApplicationMain + 1176\r\n36  libdyld.dylib                       0x00007fff8ef1b5ad start + 1\r\n```"},"comment":{"url":"https://api.github.com/repos/jakob/Postico/issues/comments/121338122","html_url":"https://github.com/jakob/Postico/issues/30#issuecomment-121338122","issue_url":"https://api.github.com/repos/jakob/Postico/issues/30","id":121338122,"user":{"login":"ndmeiri","id":8139148,"avatar_url":"https://avatars.githubusercontent.com/u/8139148?v=3","gravatar_id":"","url":"https://api.github.com/users/ndmeiri","html_url":"https://github.com/ndmeiri","followers_url":"https://api.github.com/users/ndmeiri/followers","following_url":"https://api.github.com/users/ndmeiri/following{/other_user}","gists_url":"https://api.github.com/users/ndmeiri/gists{/gist_id}","starred_url":"https://api.github.com/users/ndmeiri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ndmeiri/subscriptions","organizations_url":"https://api.github.com/users/ndmeiri/orgs","repos_url":"https://api.github.com/users/ndmeiri/repos","events_url":"https://api.github.com/users/ndmeiri/events{/privacy}","received_events_url":"https://api.github.com/users/ndmeiri/received_events","type":"User","site_admin":false},"created_at":"2015-07-14T18:45:41Z","updated_at":"2015-07-14T18:45:41Z","body":"Hello! Thanks for the quick response.\r\nThe build works, even if I include a typo in the expression.\r\nThanks for your help! Would you still like me to pass on the full crash report?"}}