Quoting table names when using schemaCompletionSource

Hi,

I have provided CodeMirror a schema using schemaCompletionSource which works well, although I would like schema entries selected from the autocomplete to be inserted quoted; for example in backticks.

As an example, when accessing a table with a space in the name (e.g. ABC Test), if I typing “SELECT * FROM AB”; “ABC Test” is available in the autocomplete, but when selected it is just inserted as-is; for it to be valid MySql it would need to wrap the table name in backticks as it is inserted.

I would be happy if every table/field was inserted with backticks; i.e. I don’t need CodeMirror to work out if the table name represents valid sql…

Is there a way to do this; or request this feature?

Thanks,
Ben

This patch should add such quotes when necessary.

Perfect, thank you.

Interestingly, to get backticks I had to restate the dialect in schemaCompletionSource (already added at initialisation), but that’s no big deal.

I have another related but different issue - will post separately…

Actually; I have found an issue - when the table is prefixed with a schema; it sees the “.” as a special character in the name; and ends up wrapping the schema and table names as the same identifier; e.g. `schema.table` instead of `schema`.`table`

When does a completion include a . character? I’m not managing to reproduce this.

Arrh, maybe it’s down to my miss-use of this; in my schema I sometimes have database.schema.table as the field key

Like this, if I type database. the autocomplete menu shows all schemas with tables in that database, so I can select “schema.table”, which inserts as `schema.table`

So, this may be me - but it worked well before this change :confused:

That was indeed not supported (and would behave weirdly in some situations, like when you typed the name including the dot and then tried to complete). I’ve pushed a patch that adds support for it.

That works great - thank you.