提交 02bd3f9c 编写于 作者: J jurgen

Quote identifier handle fix

SQLite SQL editor fix
上级 743ce2ae
......@@ -82,7 +82,7 @@ public final class DBUtils {
{
if (dataSource instanceof SQLDataSource) {
final String quote = ((SQLDataSource) dataSource).getSQLDialect().getIdentifierQuoteString();
return str.startsWith(quote) && str.endsWith(quote);
return quote != null && str.startsWith(quote) && str.endsWith(quote);
} else {
return false;
}
......@@ -101,6 +101,9 @@ public final class DBUtils {
{
final SQLDialect sqlDialect = dataSource.getSQLDialect();
String quoteString = sqlDialect.getIdentifierQuoteString();
if (quoteString == null) {
return str;
}
if (str.startsWith(quoteString) && str.endsWith(quoteString)) {
// Already quoted
return str;
......
......@@ -21,6 +21,7 @@ package org.jkiss.dbeaver.model.impl.sql;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.DBPIdentifierCase;
import org.jkiss.dbeaver.model.DBPKeywordType;
import org.jkiss.dbeaver.model.sql.SQLDialect;
......@@ -61,7 +62,7 @@ public class BasicSQLDialect implements SQLDialect {
return "SQL";
}
@NotNull
@Nullable
@Override
public String getIdentifierQuoteString()
{
......
......@@ -21,6 +21,7 @@ package org.jkiss.dbeaver.model.impl.sql;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.DBPIdentifierCase;
import org.jkiss.dbeaver.model.DBPKeywordType;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCDatabaseMetaData;
......@@ -74,6 +75,9 @@ public class JDBCSQLDialect extends BasicSQLDialect {
}
if (identifierQuoteString != null) {
identifierQuoteString = identifierQuoteString.trim();
if (identifierQuoteString.isEmpty()) {
identifierQuoteString = null;
}
}
try {
......@@ -195,6 +199,7 @@ public class JDBCSQLDialect extends BasicSQLDialect {
return name;
}
@Nullable
@NotNull
@Override
public String getIdentifierQuoteString()
......
......@@ -60,7 +60,7 @@ public interface SQLDialect extends ICommentsSupport {
*
* @return the quoting string or a space if quoting is not supported
*/
@NotNull
@Nullable
String getIdentifierQuoteString();
/**
......
......@@ -347,7 +347,10 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
Pattern aliasPattern;
SQLDialect sqlDialect = dataSource.getSQLDialect();
String quoteString = sqlDialect.getIdentifierQuoteString();
String quote = SQLConstants.STR_QUOTE_DOUBLE.equals(quoteString) ? quoteString : Pattern.quote(quoteString);
String quote = quoteString == null ? SQLConstants.STR_QUOTE_DOUBLE :
SQLConstants.STR_QUOTE_DOUBLE.equals(quoteString) ?
quoteString :
Pattern.quote(quoteString);
String catalogSeparator = sqlDialect.getCatalogSeparator();
while (token.endsWith(catalogSeparator)) token = token.substring(0, token.length() -1);
......@@ -378,7 +381,7 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
if (!CommonUtils.isEmpty(group)) {
String[] allNames = group.split(Pattern.quote(catalogSeparator));
for (String name : allNames) {
if (name.startsWith(quoteString) && name.endsWith(quoteString)) {
if (quoteString != null && name.startsWith(quoteString) && name.endsWith(quoteString)) {
name = name.substring(1, name.length() - 1);
}
nameList.add(name);
......
......@@ -19,6 +19,7 @@
package org.jkiss.dbeaver.ext.wmi.model;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.impl.sql.BasicSQLDialect;
import org.jkiss.dbeaver.model.sql.SQLStateType;
......@@ -37,6 +38,7 @@ public class WMIDialect extends BasicSQLDialect {
return "WMI";
}
@Nullable
@NotNull
@Override
public String getIdentifierQuoteString()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册