Skip to content

Support for inline queries #1018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>2.3.0-SNAPSHOT</version>
<version>2.3.0-1003-join-subselect-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data Relational Parent</name>
Expand Down
2 changes: 1 addition & 1 deletion spring-data-jdbc-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>2.3.0-SNAPSHOT</version>
<version>2.3.0-1003-join-subselect-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions spring-data-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>spring-data-jdbc</artifactId>
<version>2.3.0-SNAPSHOT</version>
<version>2.3.0-1003-join-subselect-SNAPSHOT</version>

<name>Spring Data JDBC</name>
<description>Spring Data module for JDBC repositories.</description>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>2.3.0-SNAPSHOT</version>
<version>2.3.0-1003-join-subselect-SNAPSHOT</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Expression getMappedObject(Expression expression, @Nullable RelationalPersistent

Column column = (Column) expression;
Field field = createPropertyField(entity, column.getName());
Table table = column.getTable();
TableLike table = column.getTable();

Assert.state(table != null, String.format("The column %s must have a table set.", column));

Expand Down
4 changes: 2 additions & 2 deletions spring-data-relational/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>spring-data-relational</artifactId>
<version>2.3.0-SNAPSHOT</version>
<version>2.3.0-1003-join-subselect-SNAPSHOT</version>

<name>Spring Data Relational</name>
<description>Spring Data Relational support</description>

<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>2.3.0-SNAPSHOT</version>
<version>2.3.0-1003-join-subselect-SNAPSHOT</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import java.util.function.Consumer;

import org.springframework.data.relational.core.sql.IdentifierProcessing;
import org.springframework.data.relational.core.sql.LockOptions;
import org.springframework.data.relational.core.sql.SqlIdentifier;
import org.springframework.data.relational.core.sql.Table;
import org.springframework.data.relational.core.sql.IdentifierProcessing.LetterCasing;
import org.springframework.data.relational.core.sql.IdentifierProcessing.Quoting;
import org.springframework.data.relational.core.sql.LockOptions;
import org.springframework.data.relational.core.sql.SqlIdentifier;
import org.springframework.data.relational.core.sql.TableLike;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;

Expand Down Expand Up @@ -139,7 +139,7 @@ static class PostgresLockClause implements LockClause {
@Override
public String getLock(LockOptions lockOptions) {

List<Table> tables = lockOptions.getFrom().getTables();
List<TableLike> tables = lockOptions.getFrom().getTables();
if (tables.isEmpty()) {
return "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,17 @@
/**
* {@link Segment} to select all columns from a {@link Table}.
* <p/>
* * Renders to: {@code
*
<table>
* .*} as in {@code SELECT
*
<table>
* .* FROM …}.
* Renders to: {@code <table>.*} as in {@code SELECT <table>.* FROM …}.
*
* @author Mark Paluch
* @since 1.1
* @see Table#asterisk()
*/
public class AsteriskFromTable extends AbstractSegment implements Expression {

private final Table table;
private final TableLike table;

AsteriskFromTable(Table table) {
AsteriskFromTable(TableLike table) {
super(table);
this.table = table;
}
Expand All @@ -46,7 +40,7 @@ public static AsteriskFromTable create(Table table) {
/**
* @return the associated {@link Table}.
*/
public Table getTable() {
public TableLike getTable() {
return table;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
public class Column extends AbstractSegment implements Expression, Named {

private final SqlIdentifier name;
private final Table table;
private final TableLike table;

Column(String name, Table table) {
Column(String name, TableLike table) {

super(table);
Assert.notNull(name, "Name must not be null");
Expand All @@ -41,7 +41,7 @@ public class Column extends AbstractSegment implements Expression, Named {
this.table = table;
}

Column(SqlIdentifier name, Table table) {
Column(SqlIdentifier name, TableLike table) {

super(table);
Assert.notNull(name, "Name must not be null");
Expand All @@ -57,7 +57,7 @@ public class Column extends AbstractSegment implements Expression, Named {
* @param table the table, must not be {@literal null}.
* @return the new {@link Column}.
*/
public static Column create(String name, Table table) {
public static Column create(String name, TableLike table) {

Assert.hasText(name, "Name must not be null or empty");
Assert.notNull(table, "Table must not be null");
Expand Down Expand Up @@ -341,7 +341,7 @@ public SqlIdentifier getReferenceName() {
* {@link Table}.
*/
@Nullable
public Table getTable() {
public TableLike getTable() {
return table;
}

Expand Down Expand Up @@ -370,12 +370,12 @@ static class AliasedColumn extends Column implements Aliased {

private final SqlIdentifier alias;

private AliasedColumn(String name, Table table, String alias) {
private AliasedColumn(String name, TableLike table, String alias) {
super(name, table);
this.alias = SqlIdentifier.unquoted(alias);
}

private AliasedColumn(SqlIdentifier name, Table table, SqlIdentifier alias) {
private AliasedColumn(SqlIdentifier name, TableLike table, SqlIdentifier alias) {
super(name, table);
this.alias = alias;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DefaultSelect implements Select {
private final List<OrderByField> orderBy;
private final @Nullable LockMode lockMode;

DefaultSelect(boolean distinct, List<Expression> selectList, List<Table> from, long limit, long offset,
DefaultSelect(boolean distinct, List<Expression> selectList, List<TableLike> from, long limit, long offset,
List<Join> joins, @Nullable Condition where, List<OrderByField> orderBy, @Nullable LockMode lockMode) {

this.distinct = distinct;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DefaultSelectBuilder implements SelectBuilder, SelectAndFrom, SelectFromAn

private boolean distinct = false;
private List<Expression> selectList = new ArrayList<>();
private List<Table> from = new ArrayList<>();
private List<TableLike> from = new ArrayList<>();
private long limit = -1;
private long offset = -1;
private List<Join> joins = new ArrayList<>();
Expand Down Expand Up @@ -107,7 +107,7 @@ public SelectFromAndJoin from(String table) {
* @see org.springframework.data.relational.core.sql.SelectBuilder.SelectAndFrom#from(org.springframework.data.relational.core.sql.Table)
*/
@Override
public SelectFromAndJoin from(Table table) {
public SelectFromAndJoin from(TableLike table) {
from.add(table);
return this;
}
Expand All @@ -117,7 +117,7 @@ public SelectFromAndJoin from(Table table) {
* @see org.springframework.data.relational.core.sql.SelectBuilder.SelectAndFrom#from(org.springframework.data.relational.core.sql.Table[])
*/
@Override
public SelectFromAndJoin from(Table... tables) {
public SelectFromAndJoin from(TableLike... tables) {
from.addAll(Arrays.asList(tables));
return this;
}
Expand All @@ -127,7 +127,7 @@ public SelectFromAndJoin from(Table... tables) {
* @see org.springframework.data.relational.core.sql.SelectBuilder.SelectAndFrom#from(java.util.Collection)
*/
@Override
public SelectFromAndJoin from(Collection<? extends Table> tables) {
public SelectFromAndJoin from(Collection<? extends TableLike> tables) {
from.addAll(tables);
return this;
}
Expand Down Expand Up @@ -248,7 +248,7 @@ public SelectOn join(String table) {
* @see org.springframework.data.relational.core.sql.SelectBuilder.SelectJoin#join(org.springframework.data.relational.core.sql.Table)
*/
@Override
public SelectOn join(Table table) {
public SelectOn join(TableLike table) {
return new JoinBuilder(table, this);
}

Expand All @@ -257,7 +257,7 @@ public SelectOn join(Table table) {
* @see org.springframework.data.relational.core.sql.SelectBuilder.SelectJoin#join(org.springframework.data.relational.core.sql.Table)
*/
@Override
public SelectOn leftOuterJoin(Table table) {
public SelectOn leftOuterJoin(TableLike table) {
return new JoinBuilder(table, this, JoinType.LEFT_OUTER_JOIN);
}

Expand Down Expand Up @@ -295,21 +295,21 @@ public Select build() {
*/
static class JoinBuilder implements SelectOn, SelectOnConditionComparison, SelectFromAndJoinCondition {

private final Table table;
private final TableLike table;
private final DefaultSelectBuilder selectBuilder;
private final JoinType joinType;
private @Nullable Expression from;
private @Nullable Expression to;
private @Nullable Condition condition;

JoinBuilder(Table table, DefaultSelectBuilder selectBuilder, JoinType joinType) {
JoinBuilder(TableLike table, DefaultSelectBuilder selectBuilder, JoinType joinType) {

this.table = table;
this.selectBuilder = selectBuilder;
this.joinType = joinType;
}

JoinBuilder(Table table, DefaultSelectBuilder selectBuilder) {
JoinBuilder(TableLike table, DefaultSelectBuilder selectBuilder) {
this(table, selectBuilder, JoinType.JOIN);
}

Expand Down Expand Up @@ -417,7 +417,7 @@ public SelectOn join(String table) {
* @see org.springframework.data.relational.core.sql.SelectBuilder.SelectJoin#join(org.springframework.data.relational.core.sql.Table)
*/
@Override
public SelectOn join(Table table) {
public SelectOn join(TableLike table) {
selectBuilder.join(finishJoin());
return selectBuilder.join(table);
}
Expand All @@ -427,7 +427,7 @@ public SelectOn join(Table table) {
* @see org.springframework.data.relational.core.sql.SelectBuilder.SelectJoin#leftOuterJoin(org.springframework.data.relational.core.sql.Table)
*/
@Override
public SelectOn leftOuterJoin(Table table) {
public SelectOn leftOuterJoin(TableLike table) {
selectBuilder.join(finishJoin());
return selectBuilder.leftOuterJoin(table);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@
*/
public class From extends AbstractSegment {

private final List<Table> tables;
private final List<TableLike> tables;

From(Table... tables) {
From(TableLike... tables) {
this(Arrays.asList(tables));
}

From(List<Table> tables) {
From(List<TableLike> tables) {

super(tables.toArray(new Table[] {}));
super(tables.toArray(new TableLike[] {}));

this.tables = Collections.unmodifiableList(tables);
}

public List<Table> getTables() {
public List<TableLike> getTables() {
return this.tables;
}

Expand Down
Loading