[
https://issues.apache.org/jira/browse/NETBEANS-5831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17373630#comment-17373630
]
Eric Bresie commented on NETBEANS-5831:
---
Key points from PR-2820 comments:
matthiasblaesing on Mar 21
You could create an SQL Standard Quoter, but returning the empty string here
looks strange.
ebresie on Mar 21
how should that "Quoter" be created?
I see a case like the below using SQLIdentifer to created it, but in this case
since there is no conn available, using the meta data I don't believe would be
possible.
DatabaseMetaData dmd = conn.getMetaData();
quoter = SQLIdentifiers.createQuoter(dmd)
I see a constructor for NonASCIIQuoter(String quoteString) which extends from
Quoter, however the NonASCIIQuoter is a test class so assume that isn't usable
in this case.
matthiasblaesing on Mar 22
It depends. I was the one, that pointed out, that it is highly problematic to
try to create a completion without a corresponding connection. There is
Standard SQL, so you can build a quoter based on that, but then you also need
to guess what is considered a keyword and what not.
Maybe there is a different approach possible: Don't try to be clever and use a
parser, but use keyword based completion. You could have a look at phpmyadmin
completion how it is handled there. I doubt, that they went the way of a full
parser in JS, but most probably complete based on keyword prefix matching.
ebresie on Apr 6
Just for clarification, what is meant by "Standard SQL" in this context? Are
you talking about a specific class, a "new class", or referring to "standard
SQL syntax"?
Presently the constructor/creators of Quoters that I found was mainly the
"SqlIdentifiers.createQuoter which requires a DatabaseMetadata parameter; if
the connection is not available, then assume getting the DatabaseMetaData is
not possible. There is the "NonASCIIQuoter" but this is a test class and not in
the main codebase.
As an alternative, in that code it uses the quoter to "unquote" stuff, but if a
quoter is not available (due to lack of connection), could it just return the
text as is with something like?
if (quoter == null)
return seq.token().text().toString();
ebresie on Apr 9
Looking at one of the [w3 resources SQL syntax page in identifier section
|https://www.w3resource.com/sql/sql-syntax.php#IDENTIF] it does look more
complicated.
The w3 reference mentions after "SELECT" there can be optionally "DISTINCT |
ALL" and either a wildcard ("*") or select List (i.e. identifiers). Unless I've
missed it, I'm not sure these cases are handled. Is a new issue for adding that
worth wild?
@ebresie ebresie on Apr 11
When using another tool for SQL it allows user to write without a connection
but cannot execute sql or do autocomplete without it.
@ebresie ebresie on Apr 15
Unless I'm assuming incorrectly, when no connection is active, then assume no
real need to quote/unquote any table/column would be necessary, so is going
with the below reasonable?
if (quoter == null)
return seq.token().text().toString();
@matthiasblaesing matthiasblaesing on Apr 15
My pain point: Instead of trying to fix logic, that relies hard on a
connection, why not refactor this to split connection less and connction
required codepaths, then it would be clear and you'd not need to unquote.
@ebresie ebresie on Apr 16 Author Contributor
Matthias, I appreciate the feedback. As a new commiter, I know I;m not there
yet but will get there with help.
The original scope of this ticket was...if no connection, allow some form of
auto completion without connection based details and avoid the connection
dialog from preventing futher autocompletion. As it is now I think it does this.
The remaining concenrs is how getUnquotedIdentifier behaves when no connection
is available. Initial changes was to returned "", which I realize is wrong,
risking the loss of given seq.token.txt details. Next change was to return the
results without being "unquoted" with given "return
seq.token().text().toString();"; whether it needed or not was dependent on the
database in use which if not available is where problems may occur. When quoter
is not available or used avoids risk of a null pointers and return the sequence
of text in the given context without being concerned without being "unquoted"
independent of whether a "quoter" was available or not.
When quoter is available and calls the "unquote" method found in the
SQLIdentifer.Quoter abstract class which is implemented/extended in the
DatabaseMetaDataQuoter implementation; if quoter was set correctly previously
(when DB is available) then instance of quoter should be available and all is
right with the world. However, when quoter is unavailable (not connection and
not setup earlier) then something different is needed.
So is the change suggetion to implement a new ConnectionLessQuoter or