{"action":"opened","issue":{"url":"https://api.github.com/repos/ox-it/ords/issues/714","labels_url":"https://api.github.com/repos/ox-it/ords/issues/714/labels{/name}","comments_url":"https://api.github.com/repos/ox-it/ords/issues/714/comments","events_url":"https://api.github.com/repos/ox-it/ords/issues/714/events","html_url":"https://github.com/ox-it/ords/issues/714","id":101435227,"number":714,"title":"'Edit query' button on dataset page does not always reproduce query faithfully","user":{"login":"MerielP","id":13660306,"avatar_url":"https://avatars.githubusercontent.com/u/13660306?v=3","gravatar_id":"","url":"https://api.github.com/users/MerielP","html_url":"https://github.com/MerielP","followers_url":"https://api.github.com/users/MerielP/followers","following_url":"https://api.github.com/users/MerielP/following{/other_user}","gists_url":"https://api.github.com/users/MerielP/gists{/gist_id}","starred_url":"https://api.github.com/users/MerielP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MerielP/subscriptions","organizations_url":"https://api.github.com/users/MerielP/orgs","repos_url":"https://api.github.com/users/MerielP/repos","events_url":"https://api.github.com/users/MerielP/events{/privacy}","received_events_url":"https://api.github.com/users/MerielP/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ox-it/ords/labels/Priority-Medium","name":"Priority-Medium","color":"ededed"},{"url":"https://api.github.com/repos/ox-it/ords/labels/Type-Defect","name":"Type-Defect","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-17T14:36:13Z","updated_at":"2015-08-17T14:36:13Z","closed_at":null,"body":"To reproduce this bug, view a dynamic dataset whose query contains an ORDER BY clause. Click the 'Edit query' button that appears at the top of the screen. Note that the ORDER BY clause doesn't appear on the SQL query page.\r\n\r\nI haven't done a systematic check of which types of query don't appear properly, but a couple of examples are given below:\r\n\r\n'SELECT m.id, p.title, p.first_name , p.surname , m.verbatim_name , c.club_name , m.joining_date , m.leaving_date FROM club_memberships m JOIN clubs c ON m.club_id = c.id JOIN people p ON m.people_id = p.id ORDER BY \"surname\" asc'\r\n- As noted above, the ORDER BY clause disappears. The query still works, but (obviously) without the ordering.\r\n\r\n'SELECT \"tblarticles\".\"title\" AS \"Title\",(EXTRACT (YEAR FROM CURRENT_DATE))-\"tblarticles\".\"year\" AS \"Years since publication\" FROM \"tblarticles\"'\r\n- This one gets considerably more screwed up. The SELECT field is OK, but the FROM field just contains 'CURRENT_DATE))-\"tblarticles\".\"year\" AS \"Years since publication\"' - the table name part gets omitted, and consequently the query doesn't work. (I assume the extra FROM is what's causing confusion here - as in issue #710.)\r\n"}}