{"action":"created","issue":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/3569","labels_url":"https://api.github.com/repos/nim-lang/Nim/issues/3569/labels{/name}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/3569/comments","events_url":"https://api.github.com/repos/nim-lang/Nim/issues/3569/events","html_url":"https://github.com/nim-lang/Nim/issues/3569","id":118241215,"number":3569,"title":"db_postgres: serious \"static\" args bug","user":{"login":"theduke","id":241621,"avatar_url":"https://avatars.githubusercontent.com/u/241621?v=3","gravatar_id":"","url":"https://api.github.com/users/theduke","html_url":"https://github.com/theduke","followers_url":"https://api.github.com/users/theduke/followers","following_url":"https://api.github.com/users/theduke/following{/other_user}","gists_url":"https://api.github.com/users/theduke/gists{/gist_id}","starred_url":"https://api.github.com/users/theduke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theduke/subscriptions","organizations_url":"https://api.github.com/users/theduke/orgs","repos_url":"https://api.github.com/users/theduke/repos","events_url":"https://api.github.com/users/theduke/events{/privacy}","received_events_url":"https://api.github.com/users/theduke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-22T05:27:00Z","updated_at":"2015-11-22T05:33:08Z","closed_at":null,"body":"I found a big bug in db_postgres:\r\n\r\n```nim\r\nimport db_postgres\r\nimport strutils\r\n\r\nvar con = open(\"\", \"\", \"\", \"postgresql://user:pw@localhost/test\")\r\ncon.exec(SqlQuery(\"DROP TABLE tags\"))\r\ncon.exec(SqlQuery(\"CREATE TABLE tags(id serial UNIQUE, name varchar(255))\"))\r\n\r\nfor i in 1..10:\r\n  var name = \"t\" & $i\r\n  echo(name)\r\n  discard con.getRow(\r\n    SqlQuery(\"INSERT INTO tags(name) VALUES(?) RETURNING id\"), [name])\r\n\r\n```\r\n\r\nThe insert statement somehow always reuses the arguments from the first call with \"t1\" as tag name.\r\nThe resulting rows in the database all have 'name': \"t1\" instead of \"t1\", \"t2\", ...\r\n\r\nNim 0.12.1\r\n"},"comment":{"url":"https://api.github.com/repos/nim-lang/Nim/issues/comments/158714848","html_url":"https://github.com/nim-lang/Nim/issues/3569#issuecomment-158714848","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/3569","id":158714848,"user":{"login":"theduke","id":241621,"avatar_url":"https://avatars.githubusercontent.com/u/241621?v=3","gravatar_id":"","url":"https://api.github.com/users/theduke","html_url":"https://github.com/theduke","followers_url":"https://api.github.com/users/theduke/followers","following_url":"https://api.github.com/users/theduke/following{/other_user}","gists_url":"https://api.github.com/users/theduke/gists{/gist_id}","starred_url":"https://api.github.com/users/theduke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theduke/subscriptions","organizations_url":"https://api.github.com/users/theduke/orgs","repos_url":"https://api.github.com/users/theduke/repos","events_url":"https://api.github.com/users/theduke/events{/privacy}","received_events_url":"https://api.github.com/users/theduke/received_events","type":"User","site_admin":false},"created_at":"2015-11-22T05:33:08Z","updated_at":"2015-11-22T05:33:08Z","body":"It must be some issue with how the arguments are treated.\r\nThis works fine:\r\n\r\n```nim\r\nimport db_postgres\r\nimport strutils\r\n\r\nvar con = open(\"\", \"\", \"\", \"postgresql://theduke:theduke@localhost/test\")\r\ncon.exec(SqlQuery(\"DROP TABLE tags\"))\r\ncon.exec(SqlQuery(\"CREATE TABLE tags(id serial UNIQUE, name varchar(255))\"))\r\n\r\nfor i in 1..10:\r\n  var name = \"t\" & $i\r\n  echo(name)\r\n  discard con.getRow(\r\n    SqlQuery(\"INSERT INTO tags(name) VALUES(\\'$1\\') RETURNING id\" % [name]))\r\n```"}}