Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try out CodeMirror SQL hints #949

Closed
simonw opened this issue Aug 24, 2020 · 5 comments
Closed

Try out CodeMirror SQL hints #949

simonw opened this issue Aug 24, 2020 · 5 comments

Comments

@simonw
Copy link
Owner

simonw commented Aug 24, 2020

It would also be interesting to try out the SQL hint mode, which can autocomplete against tables and columns. This demo shows how to configure that: https://codemirror.net/mode/sql/

Some missing documentation: https://stackoverflow.com/questions/20023381/codemirror-how-add-tables-to-sql-hint
Originally posted by @simonw in #948 (comment)

@simonw simonw added the small label Aug 24, 2020
@simonw
Copy link
Owner Author

simonw commented Aug 24, 2020

I think this requires three extra files from https://github.com/codemirror/CodeMirror/tree/5.57.0/addon/hint

  • show-hint.css
  • show-hint.js
  • sql-hint.js

@simonw
Copy link
Owner Author

simonw commented Aug 24, 2020

I'm attracted to this because of how good GraphiQL is for auto-completing queries. But I realize there's a problem here: GraphQL is designed to be autocomplete-friendly, but SQL is not. If you type select and it doesn't know what's going in the from clause it can't give you good column autocomplete, for example.

@simonw
Copy link
Owner Author

simonw commented Nov 1, 2020

I'm not going to do any more work on this - SQL isn't an auto-complete friendly enough language.

@simonw simonw closed this as completed Nov 1, 2020
@simonw simonw added the wontfix label Nov 1, 2020
@mhkeller
Copy link

mhkeller commented Nov 2, 2023

FWIW, code mirror 6 now has this standard although if you want table-specific suggestions, you'd have to handle parsing out which table the user is querying yourself.

@simonw
Copy link
Owner Author

simonw commented Nov 3, 2023

Datasette is using that now, see:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants