[#771] Some literals are not properly escaped with quotes, yet, e.g. UDT identifiers

This commit is contained in:
Lukas Eder 2011-07-30 17:49:30 +00:00
parent 5a8d877225
commit 68fe91e612
6 changed files with 35 additions and 16 deletions

View File

@ -304,18 +304,14 @@ implements
.sql(".*, row_number() over (order by ");
if (getOrderBy().isEmpty()) {
// TODO [#771] Check whether this literal should be escaped
context.sql(getSelect().get(0).getName());
context.literal(getSelect().get(0).getName());
}
else {
String separator = "";
for (SortField<?> field : getOrderBy()) {
// TODO [#771] Check whether this literal should be escaped
context.sql(separator)
.sql(field.getName())
.literal(field.getName())
.sql(" ")
.sql(field.getOrder().toSQL());

View File

@ -71,9 +71,7 @@ class ArrayConstant<T> extends AbstractField<T> {
@Override
public final void toSQL(RenderContext context) {
if (context.inline()) {
// TODO [#771] Check if this should be escaped as a literal
context.sql(array.getName());
context.literal(array.getName());
context.sql("(");
String separator = "";

View File

@ -305,4 +305,31 @@ class DefaultBindContext extends AbstractContext<BindContext> implements BindCon
return this;
}
// ------------------------------------------------------------------------
// Object API
// ------------------------------------------------------------------------
@Override
public final String toString() {
StringBuilder sb = new StringBuilder();
sb.append("binding [index ");
sb.append(index);
sb.append("]\ndeclaring [");
if (declareFields) {
sb.append("fields");
}
else if (declareTables) {
sb.append("tables");
}
else {
sb.append("-");
}
sb.append("]");
return sb.toString();
}
}

View File

@ -193,7 +193,7 @@ public final class FieldTypeHelper {
}
// In Postgres, some additional casting must be done in some cases...
// TODO: Improve this implementation with #215 (cast support)
// TODO: Improve this implementation with [#215] (cast support)
else if (context.getDialect() == SQLDialect.POSTGRES) {
// Postgres needs explicit casting for array types
@ -202,10 +202,10 @@ public final class FieldTypeHelper {
context.sql(getDataType(context.getDialect(), type).getCastTypeName(context));
}
// TODO [#771] Check if this type literal should be escaped
// ... and also for enum types
else if (EnumType.class.isAssignableFrom(type)) {
context.sql("?::");
context.sql(((EnumType) value).getName());
context.literal(((EnumType) value).getName());
}
else {

View File

@ -87,7 +87,6 @@ public class ParameterImpl<T> extends AbstractNamedTypeProviderQueryPart<T> impl
@Override
public final void toSQL(RenderContext context) {
// TODO [#771] Check if this should be an escaped literal
context.sql(getName());
context.literal(getName());
}
}

View File

@ -96,8 +96,7 @@ public class UDTFieldImpl<R extends UDTRecord<R>, T> extends AbstractField<T> im
@Override
public final void toSQL(RenderContext context) {
// TODO [#771] Check if this should be escaped as literal
context.sql(getName());
context.literal(getName());
}
@Override