[#3437] QualifiedField does not respect RenderContext.qualify()

This commit is contained in:
Lukas Eder 2014-07-22 15:44:58 +02:00
parent e023c7177e
commit 9fb8f8874f
3 changed files with 33 additions and 5 deletions

View File

@ -272,6 +272,21 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
assertEquals(Integer.valueOf(1), books.getValue(1, TBook_AUTHOR_ID()));
}
public void testPlainSQLInsert() throws Exception {
jOOQAbstractTest.reset = false;
assertEquals(1, create()
.insertInto(
tableByName(TAuthor().getName()),
fieldByName(TAuthor().getName(), TAuthor_ID().getName()),
fieldByName(TAuthor().getName(), TAuthor_LAST_NAME().getName()))
.values(3, "X")
.execute()
);
assertEquals(3, create().fetchCount(TAuthor()));
}
public void testPlainSQLWithSelfJoins() throws Exception {
// [#1860] In case of ambiguous field names in plain SQL, access by

View File

@ -1404,6 +1404,11 @@ public abstract class jOOQAbstractTest<
new PlainSQLTests(this).testPlainSQL();
}
@Test
public void testPlainSQLInsert() throws Exception {
new PlainSQLTests(this).testPlainSQLInsert();
}
@Test
public void testPlainSQLWithSelfJoins() throws Exception {
new PlainSQLTests(this).testPlainSQLWithSelfJoins();

View File

@ -72,12 +72,20 @@ class QualifiedField<T> extends AbstractField<T> {
@Override
public final void accept(Context<?> ctx) {
String separator = "";
for (String string : sql) {
ctx.sql(separator);
ctx.literal(string);
separator = ".";
// [#3437] Fully qualify this field only if allowed in the current context
if (ctx.qualify()) {
String separator = "";
for (String string : sql) {
ctx.sql(separator);
ctx.literal(string);
separator = ".";
}
}
else {
ctx.literal(sql[sql.length - 1]);
}
}
}