PostgreSQL autocomplete incorrect for quoted tables

In PostgreSQL, object names will be double quoted for some cases. When we try to use it in CM autocomplete, it adds extra double quotes. Is there a way to disable it?
https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge1N0YXRlRWZmZWN0fSBmcm9tICdAY29kZW1pcnJvci9zdGF0ZSc7CmltcG9ydCB7c3FsLCBQb3N0Z3JlU1FMLCBzY2hlbWFDb21wbGV0aW9uU291cmNlfSBmcm9tICJAY29kZW1pcnJvci9sYW5nLXNxbCIKCmxldCBlZGl0b3IgPSBuZXcgRWRpdG9yVmlldyh7CiAgZG9jOiAiU0VMRUNUICogRlJPTSBhYmMiLAogIGV4dGVuc2lvbnM6IFsKICAgIGJhc2ljU2V0dXAsIAogICAgc3FsKHsKICAgICAgZGlhbGVjdDogUG9zdGdyZVNRTAogICAgfSkKICBdLAogIHBhcmVudDogZG9jdW1lbnQuYm9keQp9KQoKbGV0IG15U2NoZW1hID0geyAnYWJjLiJQZXJzb24iJzogWyAnaWQnLCAnbmFtZScgXSwgJ2FiYy5hbmltYWwnOiBbICdpZCcsICduYW1lJyBdIH07CmVkaXRvci5kaXNwYXRjaCh7CiAgZWZmZWN0czogU3RhdGVFZmZlY3QuYXBwZW5kQ29uZmlnLm9mKAogICAgUG9zdGdyZVNRTC5sYW5ndWFnZS5kYXRhLm9mKHsKICAgICAgYXV0b2NvbXBsZXRlOiBzY2hlbWFDb21wbGV0aW9uU291cmNlKHtzY2hlbWE6IG15U2NoZW1hfSksCiAgICAgIAogICAgfSkKICApCn0pOw==

Don’t quote "Person" in your schema definition.

The quote is needed by Postgresql. If I don’t add the quotes then it’s incorrect.

The CodeMirror schema notation doesn’t support quotes there, so adding them simply doesn’t mean anything.

That being said, it seems that we should auto-quote names with upper-case characters. This patch adds that.

hi @marijn,
There is a different meaning of quotes in PostgreSQL and it’s not just for upper case.
I think it would be best if we can support quotes.

Hi @marijn,
The commit doesn’t fixes anything for PostgreSQL side. In fact, quoting should be best left to PostgreSQL as it is a very complex decision whether to quote or not.
Allow quoting in autocomplete is the only solution.

Hi @marijn,
I tested with lang-sql@6.5.5, and the autocomplete still doesn’t work for quoted tables.
Firstly, it adds extra quotes even if the table is quoted. Secondly, columns are not showing up for quoted table alias name.

I told you, do not quote the table name in your schema definition for CodeMirror. That doesn’t work.

I understood what you said. But that’s part of PostgreSQL, I cannot decide what to quote and what not. PostgreSQL decides. In fact, if we don’t quote then query won’t run and we’ll need to manually add those quotes. Auto-Quoting based on upper case chars is not enough.

Let me share an example with you. Below is a valid table name, but requires quotes:
CREATE TABLE IF NOT EXISTS “some@table”
(
)

No, you’re not understanding what I said. I know how Postgres works. What I am telling you is to not quote the names when defining the schemaCompletions, because that format doesn’t use quotes.

Oh my bad! I didn’t realise it works. I tested it now. :zipper_mouth_face:
I am extremely sorry for wasting your time on this. I should have tested it first. Thank you!