{"action":"closed","issue":{"url":"https://api.github.com/repos/marcoscleison/cdo/issues/16","repository_url":"https://api.github.com/repos/marcoscleison/cdo","labels_url":"https://api.github.com/repos/marcoscleison/cdo/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/marcoscleison/cdo/issues/16/comments","events_url":"https://api.github.com/repos/marcoscleison/cdo/issues/16/events","html_url":"https://github.com/marcoscleison/cdo/issues/16","id":296813201,"number":16,"title":"Forall is acting funny!","user":{"login":"buddha314","id":630441,"avatar_url":"https://avatars0.githubusercontent.com/u/630441?v=4","gravatar_id":"","url":"https://api.github.com/users/buddha314","html_url":"https://github.com/buddha314","followers_url":"https://api.github.com/users/buddha314/followers","following_url":"https://api.github.com/users/buddha314/following{/other_user}","gists_url":"https://api.github.com/users/buddha314/gists{/gist_id}","starred_url":"https://api.github.com/users/buddha314/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buddha314/subscriptions","organizations_url":"https://api.github.com/users/buddha314/orgs","repos_url":"https://api.github.com/users/buddha314/repos","events_url":"https://api.github.com/users/buddha314/events{/privacy}","received_events_url":"https://api.github.com/users/buddha314/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-02-13T17:01:23Z","updated_at":"2018-02-13T19:51:27Z","closed_at":"2018-02-13T19:51:27Z","author_association":"COLLABORATOR","body":"Here is a sample, tell me what you think.\r\n\r\n```chapel\r\n/*\r\nCREATE AND POPULATE THE TABLE WITH\r\n\r\nDROP TABLE IF EXISTS r.cho_named_edges;\r\nCREATE TABLE r.cho_named_edges\r\n(\r\n from_nm text\r\n, to_nm text\r\n);\r\nINSERT INTO r.cho_named_edges (from_nm, to_nm) VALUES\r\n  ('star lord', 'gamora') , ('star lord', 'groot')\r\n, ('star lord', 'drax') , ('gamora', 'drax')\r\n, ('groot', 'drax') , ('drax', 'rocket')\r\n, ('rocket', 'mantis') , ('mantis', 'yondu')\r\n, ('mantis', 'nebula') , ('yondu', 'nebula')\r\n;\r\n\r\n\r\nchpl -M/Users/buddha/github/cdo/src/ faerr.chpl\r\n\r\n\r\n */\r\nuse Cdo, Postgres;\r\n\r\nvar DB_HOST=\"localhost\",\r\n    DB_USER=\"buddha\",\r\n    DB_PWD=\"buddha\",\r\n    DB_NAME=\"buddha\",\r\n    con = PgConnectionFactory(host=DB_HOST, user=DB_USER, database=DB_NAME, passwd=DB_PWD);\r\n\r\nvar q = \"\"\"\r\nSELECT from_nm, to_nm FROM r.cho_named_edges ORDER BY from_nm, to_nm;\r\n\"\"\";\r\n\r\nvar cursor = con.cursor();\r\ncursor.query(q);\r\n\r\n/*\r\n Should return 10 rows\r\n */\r\nvar i: int = 0;\r\nwriteln(\"=== FOR LOOP ===\");\r\nfor row in cursor {\r\n  writeln(\"from: \", row['from_nm'], \"\\tto: \", row['to_nm']);\r\n  i += 1;\r\n}\r\nwriteln(\"Expected 10 rows, got \", i);\r\n\r\nvar cursor2 = con.cursor();\r\ncursor2.query(q);\r\n\r\n/*\r\n Should also return 10 rows\r\n */\r\nvar j:int = 0;\r\nwriteln(\"\\n=== FORALL LOOP ===\");\r\nforall row in cursor with (+ reduce j) {\r\n  writeln(\"from: \", row['from_nm'], \"\\tto: \", row['to_nm']);\r\n  j += 1;\r\n}\r\nwriteln(\"Expected 10 rows, got \", j);\r\nwriteln(\"Okay, I usually get 9 rows, not 10\");\r\n```\r\n\r\nUpdated with @daviditen  answer to [this SO](https://stackoverflow.com/questions/48771784/how-do-i-count-iterations-in-a-chapel-forall-loop/48772231#48772231) "}}
{"actor":{"display_login":"marcoscleison"}}