{"action":"created","issue":{"url":"https://api.github.com/repos/YinaZ/AccessMapLite/issues/2","repository_url":"https://api.github.com/repos/YinaZ/AccessMapLite","labels_url":"https://api.github.com/repos/YinaZ/AccessMapLite/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/YinaZ/AccessMapLite/issues/2/comments","events_url":"https://api.github.com/repos/YinaZ/AccessMapLite/issues/2/events","html_url":"https://github.com/YinaZ/AccessMapLite/issues/2","id":214283115,"number":2,"title":"Error \"Unexpected Column 'cost' type\" during query in app.js","user":{"login":"YinaZ","id":20526571,"avatar_url":"https://avatars2.githubusercontent.com/u/20526571?v=3","gravatar_id":"","url":"https://api.github.com/users/YinaZ","html_url":"https://github.com/YinaZ","followers_url":"https://api.github.com/users/YinaZ/followers","following_url":"https://api.github.com/users/YinaZ/following{/other_user}","gists_url":"https://api.github.com/users/YinaZ/gists{/gist_id}","starred_url":"https://api.github.com/users/YinaZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YinaZ/subscriptions","organizations_url":"https://api.github.com/users/YinaZ/orgs","repos_url":"https://api.github.com/users/YinaZ/repos","events_url":"https://api.github.com/users/YinaZ/events{/privacy}","received_events_url":"https://api.github.com/users/YinaZ/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-15T04:59:33Z","updated_at":"2017-04-07T20:35:50Z","closed_at":"2017-04-07T20:35:50Z","body":"According to the tutorial (also what I did while developing), the `grade` COLUMN in the `routing_info` table is initialized like this:\r\n```\r\nALTER TABLE routing_info ADD COLUMN grade NUMERIC(6, 4);\r\n```\r\nSo the data type is numeric. But when I try to use the dijkstra algorithm from pgRouting and pass in `grade` COLUMN as the `cost` parameter like this (below is a part of the long query stored as string in `app.js` line 30):\r\n```\r\nCREATE OR REPLACE FUNCTION getRoute(source integer, target integer)\r\nRETURNS TABLE(seq integer, path_seq integer, node bigint, edge bigint, cost double precision, agg_cost double precision) AS $$\r\n  SELECT d.seq, d.path_seq, d.node, d.edge, d.cost, d.agg_cost \r\n  FROM pgr_dijkstra('SELECT osm_id AS id, source, target, grade AS cost FROM routing_info WHERE grade IS NOT NULL', $1, $2, false) AS d;\r\n$$ LANGUAGE sql;\r\n```\r\nI get this following error when I use `getRoute` function:\r\n```\r\nosm=# SELECT * FROM getRoute(22986, 22992);\r\nERROR:  Unexpected Column 'cost' type. Expected ANY-NUMERICAL\r\nCONTEXT:  PL/pgSQL function pgr_dijkstra(text,bigint,bigint,boolean) line 4 at RETURN QUERY\r\nSQL function \"getroute\" statement 1\r\n\r\n```\r\nSo currently I'm passing `ST_Length(geom) + grade` as the `cost` parameter like this to avoid the error, so that the app can still run:\r\n```\r\nCREATE OR REPLACE FUNCTION getRoute(source integer, target integer)\r\nRETURNS TABLE(seq integer, path_seq integer, node bigint, edge bigint, cost double precision, agg_cost double precision) AS $$\r\n  SELECT d.seq, d.path_seq, d.node, d.edge, d.cost, d.agg_cost \r\n  FROM pgr_dijkstra('SELECT osm_id AS id, source, target, ST_Length(geom) + grade AS cost FROM routing_info WHERE grade IS NOT NULL', $1, $2, false) AS d;\r\n$$ LANGUAGE sql;\r\n```\r\nHowever, there should be a way to only pass in `grade`."},"comment":{"url":"https://api.github.com/repos/YinaZ/AccessMapLite/issues/comments/292645084","html_url":"https://github.com/YinaZ/AccessMapLite/issues/2#issuecomment-292645084","issue_url":"https://api.github.com/repos/YinaZ/AccessMapLite/issues/2","id":292645084,"user":{"login":"YinaZ","id":20526571,"avatar_url":"https://avatars2.githubusercontent.com/u/20526571?v=3","gravatar_id":"","url":"https://api.github.com/users/YinaZ","html_url":"https://github.com/YinaZ","followers_url":"https://api.github.com/users/YinaZ/followers","following_url":"https://api.github.com/users/YinaZ/following{/other_user}","gists_url":"https://api.github.com/users/YinaZ/gists{/gist_id}","starred_url":"https://api.github.com/users/YinaZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YinaZ/subscriptions","organizations_url":"https://api.github.com/users/YinaZ/orgs","repos_url":"https://api.github.com/users/YinaZ/repos","events_url":"https://api.github.com/users/YinaZ/events{/privacy}","received_events_url":"https://api.github.com/users/YinaZ/received_events","type":"User","site_admin":false},"created_at":"2017-04-07T20:35:50Z","updated_at":"2017-04-07T20:35:50Z","body":"The issue is resolved by casting the `grade` column to type `double precision`. "}}
{"actor":{"display_login":"YinaZ"}}