{"action":"opened","issue":{"url":"https://api.github.com/repos/orangemug/sql-stamp/issues/9","labels_url":"https://api.github.com/repos/orangemug/sql-stamp/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/orangemug/sql-stamp/issues/9/comments","events_url":"https://api.github.com/repos/orangemug/sql-stamp/issues/9/events","html_url":"https://github.com/orangemug/sql-stamp/issues/9","id":117157177,"number":9,"title":"Explicit param passing syntax","user":{"login":"oliverbrooks","id":17350,"avatar_url":"https://avatars.githubusercontent.com/u/17350?v=3","gravatar_id":"","url":"https://api.github.com/users/oliverbrooks","html_url":"https://github.com/oliverbrooks","followers_url":"https://api.github.com/users/oliverbrooks/followers","following_url":"https://api.github.com/users/oliverbrooks/following{/other_user}","gists_url":"https://api.github.com/users/oliverbrooks/gists{/gist_id}","starred_url":"https://api.github.com/users/oliverbrooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliverbrooks/subscriptions","organizations_url":"https://api.github.com/users/oliverbrooks/orgs","repos_url":"https://api.github.com/users/oliverbrooks/repos","events_url":"https://api.github.com/users/oliverbrooks/events{/privacy}","received_events_url":"https://api.github.com/users/oliverbrooks/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-16T16:03:41Z","updated_at":"2015-11-16T16:03:41Z","closed_at":null,"body":"What do you think of passing params to sql requires?\r\n\r\nAim would be to explicitly tell the requires what variables they will receive and avoid mixed use of variables. This becomes especially useful when there are lots of nested requires or you want to use something generic like `id` or `userId` for different things across files.\r\n\r\nSeems like it would be more 'nodey' self contained file type thing.\r\n\r\n```js\r\nvar sqlStamp = require(\"sql-stamp\");\r\n\r\nsql(\"foo.sql\", {\r\n  id: 5, \r\n  badger: \"badger\"\r\n})\r\n```\r\n\r\nfoo.sql\r\n\r\n```sql\r\nSELECT\r\n  -- Pass the params through explicitly\r\n  {> some_select_query({fooId: id, badger: badger }) }\r\nFROM\r\n  some_table\r\n```\r\n\r\nsome_select_query.sql\r\n\r\n```sql\r\n\"some_table\".*,\r\n-- 'badger` was passed straight through\r\n{ badger } AS \"badger\",\r\n(\r\n  SELECT\r\n    row_to_json(*)\r\n  FROM\r\n    some_other_table\r\n  WHERE\r\n    -- note that 'id' is 'fooId' here\r\n    some_other_table.id = {fooId}\r\n  LIMIT\r\n    1\r\n) AS \"subQueryData\"\r\n```"}}