[#3480] Add XXXContext.dialect() and XXXContext.family() for convenience
This commit is contained in:
parent
5bbe2fc026
commit
a6c563c66e
@ -67,6 +67,22 @@ public interface Context<C extends Context<C>> {
|
||||
*/
|
||||
Configuration configuration();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect()</code>.
|
||||
*/
|
||||
SQLDialect dialect();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect#family()} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect().family()</code>.
|
||||
*/
|
||||
SQLDialect family();
|
||||
|
||||
/**
|
||||
* Get all custom data from this <code>Context</code>.
|
||||
* <p>
|
||||
|
||||
@ -68,6 +68,22 @@ public interface DAO<R extends TableRecord<R>, P, T> {
|
||||
*/
|
||||
Configuration configuration();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect()</code>.
|
||||
*/
|
||||
SQLDialect dialect();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect#family()} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect().family()</code>.
|
||||
*/
|
||||
SQLDialect family();
|
||||
|
||||
/**
|
||||
* Expose the {@link RecordMapper} that is used internally by this
|
||||
* <code>DAO</code> to map from records of type <code>R</code> to POJOs of
|
||||
|
||||
@ -123,6 +123,22 @@ public interface DSLContext {
|
||||
*/
|
||||
Configuration configuration();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect()</code>.
|
||||
*/
|
||||
SQLDialect dialect();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect#family()} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect().family()</code>.
|
||||
*/
|
||||
SQLDialect family();
|
||||
|
||||
/**
|
||||
* Map a schema to another one.
|
||||
* <p>
|
||||
|
||||
@ -115,6 +115,22 @@ public interface ExecuteContext {
|
||||
*/
|
||||
Configuration configuration();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect()</code>.
|
||||
*/
|
||||
SQLDialect dialect();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect#family()} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect().family()</code>.
|
||||
*/
|
||||
SQLDialect family();
|
||||
|
||||
/**
|
||||
* The connection to be used in this execute context.
|
||||
* <p>
|
||||
|
||||
@ -105,6 +105,22 @@ public interface RecordContext {
|
||||
*/
|
||||
Configuration configuration();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect()</code>.
|
||||
*/
|
||||
SQLDialect dialect();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect#family()} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect().family()</code>.
|
||||
*/
|
||||
SQLDialect family();
|
||||
|
||||
/**
|
||||
* The type of database interaction that is being executed.
|
||||
* <p>
|
||||
|
||||
@ -53,6 +53,22 @@ public interface TransactionContext {
|
||||
*/
|
||||
Configuration configuration();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect()</code>.
|
||||
*/
|
||||
SQLDialect dialect();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect#family()} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect().family()</code>.
|
||||
*/
|
||||
SQLDialect family();
|
||||
|
||||
/**
|
||||
* A user-defined transaction object, possibly obtained from
|
||||
* {@link TransactionProvider#begin(TransactionContext)}.
|
||||
|
||||
@ -94,6 +94,22 @@ public interface VisitContext {
|
||||
*/
|
||||
Configuration configuration();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect()</code>.
|
||||
*/
|
||||
SQLDialect dialect();
|
||||
|
||||
/**
|
||||
* The {@link SQLDialect#family()} wrapped by this context.
|
||||
* <p>
|
||||
* This method is a convenient way of accessing
|
||||
* <code>configuration().dialect().family()</code>.
|
||||
*/
|
||||
SQLDialect family();
|
||||
|
||||
/**
|
||||
* The most recent clause that was encountered through
|
||||
* {@link Context#start(Clause)}.
|
||||
|
||||
@ -245,6 +245,16 @@ abstract class AbstractContext<C extends Context<C>> implements Context<C> {
|
||||
return AbstractContext.this.configuration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect dialect() {
|
||||
return Utils.configuration(configuration()).dialect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect family() {
|
||||
return dialect().family();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Clause clause() {
|
||||
return visitClauses.peekLast();
|
||||
@ -306,6 +316,16 @@ abstract class AbstractContext<C extends Context<C>> implements Context<C> {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect dialect() {
|
||||
return Utils.configuration(configuration()).dialect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect family() {
|
||||
return dialect().family();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Map<Object, Object> data() {
|
||||
return data;
|
||||
|
||||
@ -280,6 +280,16 @@ public class DefaultDSLContext implements DSLContext, Serializable {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLDialect dialect() {
|
||||
return Utils.configuration(configuration()).dialect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SQLDialect family() {
|
||||
return dialect().family();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Schema map(Schema schema) {
|
||||
return Utils.getMappedSchema(configuration, schema);
|
||||
|
||||
@ -65,6 +65,7 @@ import org.jooq.Record;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.ResultQuery;
|
||||
import org.jooq.Routine;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Truncate;
|
||||
import org.jooq.Update;
|
||||
import org.jooq.tools.jdbc.JDBCUtils;
|
||||
@ -410,6 +411,16 @@ class DefaultExecuteContext implements ExecuteContext {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect dialect() {
|
||||
return Utils.configuration(configuration()).dialect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect family() {
|
||||
return dialect().family();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void connectionProvider(ConnectionProvider provider) {
|
||||
this.connectionProvider = provider;
|
||||
|
||||
@ -48,6 +48,7 @@ import org.jooq.ExecuteType;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RecordContext;
|
||||
import org.jooq.RecordType;
|
||||
import org.jooq.SQLDialect;
|
||||
|
||||
/**
|
||||
* A default implementation for {@link RecordContext}.
|
||||
@ -89,6 +90,16 @@ class DefaultRecordContext implements RecordContext {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect dialect() {
|
||||
return Utils.configuration(configuration()).dialect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect family() {
|
||||
return dialect().family();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ExecuteType type() {
|
||||
return type;
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Transaction;
|
||||
import org.jooq.TransactionContext;
|
||||
|
||||
@ -62,6 +63,16 @@ class DefaultTransactionContext implements TransactionContext {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect dialect() {
|
||||
return Utils.configuration(configuration()).dialect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final SQLDialect family() {
|
||||
return dialect().family();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Transaction transaction() {
|
||||
return transaction;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user