Title: Execute SQL doesn't play nicely with one-line comments · Issue #1004 · sqlitebrowser/sqlitebrowser · GitHub
Open Graph Title: Execute SQL doesn't play nicely with one-line comments · Issue #1004 · sqlitebrowser/sqlitebrowser
X Title: Execute SQL doesn't play nicely with one-line comments · Issue #1004 · sqlitebrowser/sqlitebrowser
Description: Single-line SQL comments cause peculiar behaviour if run in the "Execute SQL" tab. Say I run the following: -- This comment prevents line count working and "changes the database" SELECT * FROM events WHERE logid=81991 AND type='content' ...
Open Graph Description: Single-line SQL comments cause peculiar behaviour if run in the "Execute SQL" tab. Say I run the following: -- This comment prevents line count working and "changes the database" SELECT * FROM even...
X Description: Single-line SQL comments cause peculiar behaviour if run in the "Execute SQL" tab. Say I run the following: -- This comment prevents line count working and "changes the database"...
Opengraph URL: https://github.com/sqlitebrowser/sqlitebrowser/issues/1004
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Execute SQL doesn't play nicely with one-line comments","articleBody":"Single-line SQL comments cause peculiar behaviour if run in the \"Execute SQL\" tab.\r\n\r\nSay I run the following:\r\n`-- This comment prevents line count working and \"changes the database\"`\r\n`SELECT * FROM events WHERE logid=81991 AND type='content'`\r\nthen \r\n- I don't get the usual \"N rows returned\" message\r\n- the database is locked and Write/Revert changes are enabled\r\n- the correct result is returned\r\n\r\nAlternatively, if I run:\r\n`SELECT * FROM events WHERE logid=81991 AND type='content'`\r\n`-- This comment causes an error`\r\nthen \r\n- I get an \"Error executing query: ...\" response\r\n- no result is returned\r\n\r\nIn this case I can see that the SQL submitted by the application has had the line breaks removed, so the extra `SELECT COUNT(*) ...` that's added to give a line count is syntactically wrong, as the terminating `);` has become commented-out.\r\n\r\nFinally (so far), if I try to execute:\r\n`SELECT 40+2 -- get the answer`\r\n`AS answer`\r\n(N.B. `AS` is at the start of the line) then \r\n- I get an \"Error executing query: ...\" response\r\n- no result is returned\r\n\r\nIn this case the comment and newline have been removed completely, with the result that what's executed is `SELECT 40+2AS answer` (no whitespace between `2` and `AS`).\r\n\r\nI'd suggest the quick approach is to replace single-line comments with a single space, if you don't mind them being discarded from the submitted SQL. If you want to leave them in then you can't discard the newlines, as they're syntactically significant...\r\n\r\n\u003c!--\r\n\r\nThanks for coming here to report an issue. :)\r\n\r\nPlease describe it in this section, fill out the correct check boxes\r\nbelow with an \"x\", then click the \"Submit new issue\" button at the bottom\r\n\r\n-->\r\n\r\n\r\n\r\n### Useful extra information\r\n\r\n\u003c!-- The info below often helps, please fill it out if you're able to. :) -->\r\n\r\n#### I'm opening this issue because:\r\n\r\n- [ ] DB4S is crashing\r\n- [x] DB4S has a bug\r\n- [ ] DB4S needs a feature\r\n- [ ] DB4S has another problem\r\n\r\n#### I'm using DB4S on:\r\n\r\n- [x] Windows: ( _version:_ 7___ )\r\n- [ ] Linux: ( _distro:_ ___ )\r\n- [ ] Mac OS: ( _version:_ ___ )\r\n- [ ] Other: ___\r\n\r\n#### I'm using DB4S version:\r\n\r\n- [x] 3.9.1\r\n- [ ] 3.9.0\r\n- [ ] Other: ___\r\n\r\n#### I have also:\r\n\r\n- [ ] Tried out the nightly version: https://github.com/sqlitebrowser/sqlitebrowser#windows\r\n- [x] Searched for an existing similar issue: https://github.com/sqlitebrowser/sqlitebrowser/issues?utf8=%E2%9C%93&q=is%3Aissue%20\r\n","author":{"url":"https://github.com/h4yn0nnym0u5e","@type":"Person","name":"h4yn0nnym0u5e"},"datePublished":"2017-05-03T08:25:36Z","url":"https://github.com/sqlitebrowser/sqlitebrowser/issues/1004"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d200096a-cfb7-45a2-a289-60c2b243ad68 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D57A:1007B2:3F9F7:59524:6AFD4879 |
| html-safe-nonce | eb97051f7192c3db3e6edc3cd2e304709f47c9a65db6a37adafe0981459feb6e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTdBOjEwMDdCMjozRjlGNzo1OTUyNDo2QUZENDg3OSIsInZpc2l0b3JfaWQiOiIxNTE1MjgzMTU1NTIxNDU2MjQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1175f3007d1b97122f1d58bfc6ebb219aece06c81dfa55f71f11a6554b508a00 |
| hovercard-subject-tag | issue:225913797 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sqlitebrowser/sqlitebrowser/1004/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4cefdb1197623324db143f3be224bdc5c8df7f1c79d15a1236b1d490300495ca/sqlitebrowser/sqlitebrowser/issues/1004 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4cefdb1197623324db143f3be224bdc5c8df7f1c79d15a1236b1d490300495ca/sqlitebrowser/sqlitebrowser/issues/1004 |
| og:image:alt | Single-line SQL comments cause peculiar behaviour if run in the "Execute SQL" tab. Say I run the following: -- This comment prevents line count working and "changes the database" SELECT * FROM even... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | h4yn0nnym0u5e |
| hostname | github.com |
| expected-hostname | github.com |
| None | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| turbo-cache-control | no-preview |
| go-import | github.com/sqlitebrowser/sqlitebrowser git https://github.com/sqlitebrowser/sqlitebrowser.git |
| octolytics-dimension-user_id | 7454271 |
| octolytics-dimension-user_login | sqlitebrowser |
| octolytics-dimension-repository_id | 19416551 |
| octolytics-dimension-repository_nwo | sqlitebrowser/sqlitebrowser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 19416551 |
| octolytics-dimension-repository_network_root_nwo | sqlitebrowser/sqlitebrowser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width