#11058 Use unicode prefix for strings

上级 59c86092
......@@ -59,9 +59,9 @@ public abstract class SQLServerBaseTableManager<OBJECT extends SQLServerTableBas
new SQLDatabasePersistAction(
"Add table comment",
"EXEC " + SQLServerUtils.getSystemTableName(table.getDatabase(), isUpdate ? "sp_updateextendedproperty" : "sp_addextendedproperty") +
" 'MS_Description', N" + SQLUtils.quoteString(command.getObject(), command.getObject().getDescription()) + "," +
" 'schema', N'" + table.getSchema().getName() + "'," +
" '" + (table.isView() ? "view" : "table") + "', N'" + table.getName() + "'"));
" 'MS_Description', " + SQLUtils.quoteString(table, table.getDescription()) + "," +
" 'schema', " + SQLUtils.quoteString(table, table.getSchema().getName()) + "," +
" '" + (table.isView() ? "view" : "table") + "', " + SQLUtils.quoteString(table, table.getName())));
}
}
......@@ -74,7 +74,7 @@ public abstract class SQLServerBaseTableManager<OBJECT extends SQLServerTableBas
"Rename table",
"EXEC " + SQLServerUtils.getSystemTableName(object.getDatabase(), "sp_rename") +
" N'" + object.getSchema().getFullyQualifiedName(DBPEvaluationContext.DML) + "." + DBUtils.getQuotedIdentifier(object.getDataSource(), command.getOldName()) +
"' , N'" + DBUtils.getQuotedIdentifier(object.getDataSource(), command.getNewName()) + "', 'OBJECT'")
"', " + SQLUtils.quoteString(object.getDataSource(), command.getNewName()) + ", 'OBJECT'")
);
}
......
......@@ -120,9 +120,9 @@ public class SQLServerProcedureManager extends SQLServerObjectManager<SQLServerP
new SQLDatabasePersistAction(
"Add procedure comment",
"EXEC " + SQLServerUtils.getSystemTableName(database, isUpdate ? "sp_updateextendedproperty" : "sp_addextendedproperty") +
" 'MS_Description', N" + SQLUtils.quoteString(command.getObject(), command.getObject().getDescription()) + "," +
" 'schema', N'" + procedure.getContainer().getName() + "'," +
" 'procedure', N'" + procedure.getName() + "'"));
" 'MS_Description', " + SQLUtils.quoteString(procedure, procedure.getDescription()) + "," +
" 'schema', " + SQLUtils.quoteString(procedure, procedure.getContainer().getName()) + "," +
" 'procedure', " + SQLUtils.quoteString(procedure, procedure.getName())));
}
}
......
......@@ -170,10 +170,10 @@ public class SQLServerTableColumnManager extends SQLTableColumnManager<SQLServer
new SQLDatabasePersistAction(
"Add column comment",
"EXEC " + SQLServerUtils.getSystemTableName(column.getTable().getDatabase(), isUpdate ? "sp_updateextendedproperty" : "sp_addextendedproperty") +
" 'MS_Description', N" + SQLUtils.quoteString(command.getObject(), command.getObject().getDescription()) + "," +
" 'schema', N'" + column.getTable().getSchema().getName() + "'," +
" 'table', N'" + column.getTable().getName() + "'," +
" 'column', N'" + column.getName() + "'"));
" 'MS_Description', " + SQLUtils.quoteString(column, column.getDescription()) + "," +
" 'schema', " + SQLUtils.quoteString(column, column.getTable().getSchema().getName()) + "," +
" 'table', " + SQLUtils.quoteString(column, column.getTable().getName()) + "," +
" 'column', " + SQLUtils.quoteString(column, column.getName())));
}
if (totalProps > 0) {
actionList.add(new SQLDatabasePersistAction(
......
......@@ -248,4 +248,27 @@ public class SQLServerDialect extends JDBCSQLDialect {
sql.append("\nSELECT\t'Return Value' = @return_value\n\n");
sql.append("GO\n\n");
}
@Override
public boolean isQuotedString(String string) {
if (string.length() >= 3 && string.charAt(0) == 'N') {
// https://docs.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql
return super.isQuotedString(string.substring(1));
}
return super.isQuotedString(string);
}
@Override
public String getQuotedString(String string) {
return 'N' + super.getQuotedString(string);
}
@Override
public String getUnquotedString(String string) {
if (string.length() >= 3 && string.charAt(0) == 'N') {
// https://docs.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql
return super.getUnquotedString(string.substring(1));
}
return super.getUnquotedString(string);
}
}
......@@ -660,12 +660,9 @@ public final class SQLUtils {
case STRING:
case ROWID:
if (sqlDialect != null) {
strValue = sqlDialect.escapeString(strValue);
return sqlDialect.getTypeCastClause(attribute, sqlDialect.getQuotedString(strValue));
}
if (dataKind == DBPDataKind.STRING || !(strValue.startsWith("'") && strValue.endsWith("'"))) {
strValue = '\'' + strValue + '\'';
}
return sqlDialect.getTypeCastClause(attribute, strValue);
return strValue;
default:
if (sqlDialect != null) {
return sqlDialect.escapeScriptValue(attribute, value, strValue);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册