Skip to content

DATAJDBC-347 - Add missing override to SelectBuilder. #145

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 2 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>1.1.0.BUILD-SNAPSHOT</version>
<version>1.1.0.DATAJDBC-347-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data Relational Parent</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ interface SelectAndFrom extends SelectFrom {
*/
SelectAndFrom distinct();

/**
* Declare a {@link Table} to {@code SELECT … FROM}. Multiple calls to this or other {@code from} methods keep
* adding items to the select list and do not replace previously contained items.
*
* @param table the table name to {@code SELECT … FROM} must not be {@literal null} or empty.
* @return {@code this} builder.
* @see From
* @see SQL#table(String)
*/
@Override
SelectFromAndJoin from(String table);

/**
* Declare a {@link Table} to {@code SELECT … FROM}. Multiple calls to this or other {@code from} methods keep
* adding items to the select list and do not replace previously contained items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@

import static org.assertj.core.api.Assertions.*;

import java.util.ArrayList;
import java.util.List;
import java.util.OptionalLong;

import org.junit.Test;

import org.springframework.data.relational.core.sql.Join.JoinType;

/**
Expand Down Expand Up @@ -65,6 +64,23 @@ public void selectTop() {
assertThat(select.getLimit()).isEqualTo(OptionalLong.of(10));
}

@Test // DATAJDBC-347
public void selectWithWhere() {

SelectBuilder builder = StatementBuilder.select();

Table table = SQL.table("mytable");
Column foo = table.column("foo");

Comparison condition = foo.isEqualTo(SQL.literalOf("bar"));
Select select = builder.select(foo).from(table.getName()).where(condition).build();

CapturingVisitor visitor = new CapturingVisitor();
select.visit(visitor);

assertThat(visitor.enter).containsSequence(foo, table, new From(table), table, new Where(condition));
}

@Test // DATAJDBC-309
public void moreAdvancedSelect() {

Expand Down