TableLike<?> values(DSLContext ctx, RowN[] rows, String tableName, String... fieldNames) { switch (sqlDialect.family()) { case H2: List<SelectField<?>> fields = Lists.newArrayListWithCapacity(fieldNames.length); for (int i = 1; i <= fieldNames.length; i++) { fields.add(DSL.field("C" + i).as(fieldNames[i-1])); } RenderContext context = ctx.renderContext(); context.start(TABLE_VALUES) .keyword("values") .formatIndentLockStart(); boolean firstRow = true; for (Row row : rows) { if (!firstRow) { context.sql(',').formatSeparator(); } context.sql(row.toString()); firstRow = false; } context.formatIndentLockEnd() .end(TABLE_VALUES); String valuesClause = context.render(); return ctx.select(fields).from(valuesClause).asTable(tableName); default: return DSL.values(rows).as(tableName, fieldNames); } }
private final void toSQLEnd(RenderContext context) { { context.sql(" }"); } }
private final void toSQLBegin(RenderContext context) { { context.sql("{ "); } }
private final void toSQLAssign(RenderContext context) { { context.sql("? = "); } }
private final void toSQLCast(RenderContext context, DataType<?> type, int length, int precision, int scale) { context.keyword("cast").sql("("); toSQL(context, value, getType()); context.sql(" ").keyword("as").sql(" ") .sql(type.length(length).precision(precision, scale).getCastTypeName(context.configuration())) .sql(")"); }
/** * Render a list of names of the <code>NamedQueryParts</code> contained in * this list. */ static final void fieldNames(RenderContext context, Collection<? extends Field<?>> list) { String separator = ""; for (Field<?> field : list) { context.sql(separator).literal(field.getName()); separator = ", "; } }
@Override public void visitEnd(VisitContext context) { if (anyAbbreviations) { if (context.queryPartsLength() == 1) { context.renderContext().sql(" -- Bind values may have been abbreviated for DEBUG logging. Use TRACE logging for very large bind variables."); } } } }
/** * Render a list of names of the <code>NamedQueryParts</code> contained in * this list. */ static final void tableNames(RenderContext context, Collection<? extends Table<?>> list) { String separator = ""; for (Table<?> table : list) { context.sql(separator).literal(table.getName()); separator = ", "; } }
@Override public final void toSQL(RenderContext context) { context.visit(row) .sql(" ") .keyword(isNull ? "is null" : "is not null"); }
static final void pgRenderRecordCast(RenderContext render, Record value) { if (value instanceof UDTRecord) render.sql("::").visit(((UDTRecord<?>) value).getUDT().getQualifiedName()); else if (value instanceof TableRecord) render.sql("::").visit(((TableRecord<?>) value).getTable().getQualifiedName()); }
private final void toSQLAssign(RenderContext context) { switch (context.configuration().dialect().family()) { /* [pro] xx xxxx xxxxxxx xxxxxxxxxxxxxx xx xxx xxxxxx xx [/pro] */ default: context.sql("? = "); break; } }
private final void toSQLQualifiedName(RenderContext ctx) { if (ctx.qualify()) { Schema mapped = Tools.getMappedSchema(ctx.configuration(), getSchema()); if (mapped != null && !"".equals(mapped.getName())) ctx.visit(mapped) .sql('.'); } ctx.literal(getName()); }
@Override public final void toSQL(RenderContext context) { context.data(DATA_OMIT_CLAUSE_EVENT_EMISSION, true); if (context.qualify()) { context.visit(table); context.sql("."); } context.literal(getName()); context.data(DATA_OMIT_CLAUSE_EVENT_EMISSION, null); }
@Override final void sqlInline0(BindingSQLContext<U> ctx, Record value) throws SQLException { if ( ctx.family() == POSTGRES) { ctx.render().visit(inline(PostgresUtils.toPGString(value))); pgRenderRecordCast(ctx.render(), value); } else ctx.render().sql("[UDT]"); }