Skip to content

Commit 0309679

Browse files
committed
finished setting up test that reproduces the issue
1 parent ae89348 commit 0309679

File tree

2 files changed

+47
-7
lines changed

2 files changed

+47
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,58 @@
11
package com.infobip.spring.data.r2dbc.mysql;
22

3-
import com.infobip.spring.data.r2dbc.TestBase;
3+
import com.infobip.spring.data.r2dbc.*;
4+
import lombok.AllArgsConstructor;
5+
import org.assertj.core.api.BDDAssertions;
46
import org.junit.jupiter.api.Test;
57
import org.springframework.test.context.*;
8+
import reactor.core.publisher.Mono;
9+
import reactor.test.StepVerifier;
610

11+
import java.util.function.Predicate;
12+
13+
import static com.infobip.spring.data.r2dbc.QPerson.person;
14+
15+
@AllArgsConstructor
716
@ContextConfiguration(loader = MssqlExclusionContextLoader.class)
817
@ActiveProfiles("mysql")
918
@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL)
1019
public class MysqlNamedParametersSupportTest extends TestBase {
1120

21+
private final PersonRepository repository;
22+
1223
@Test
1324
void shouldNotFail() {
1425
// given
26+
var given = given(givenSavedPerson("John", "Doe"),
27+
givenSavedPerson("Johny", "Roe"),
28+
givenSavedPerson("Jane", "Doe"),
29+
givenSavedPerson("John", "Roe"),
30+
givenSavedPerson("Janie", "Doe"));
31+
1532
// when
33+
var actual = given.thenMany(repository.query(query -> query.select(repository.entityProjection())
34+
.from(person)
35+
.where(person.firstName.in("John", "Jane"))
36+
.orderBy(person.firstName.asc(),
37+
person.lastName.asc())
38+
.limit(1)
39+
.offset(1))
40+
.all());
41+
1642
// then
43+
StepVerifier.create(actual)
44+
.expectNextMatches(person("John", "Doe"))
45+
.verifyComplete();
46+
}
47+
48+
private Mono<Person> givenSavedPerson(String firstName, String lastName) {
49+
return repository.save(new Person(null, firstName, lastName));
50+
}
51+
52+
private Predicate<? super Person> person(String firstName, String lastName) {
53+
return person -> {
54+
BDDAssertions.then(person).isEqualTo(new Person(person.id(), firstName, lastName));
55+
return true;
56+
};
1757
}
1858
}

infobip-spring-data-r2dbc-querydsl/src/test/resources/db/migration/mysql/V1_0_0__base_schema.sql

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
CREATE TABLE Person (
1+
CREATE TABLE person (
22
Id BIGINT AUTO_INCREMENT,
33
FirstName NVARCHAR(20) NOT NULL,
44
LastName NVARCHAR(50) NOT NULL,
55
CONSTRAINT PK_Person PRIMARY KEY (Id)
66
);
77

8-
CREATE TABLE PersonSettings (
8+
CREATE TABLE personsettings (
99
Id BIGINT AUTO_INCREMENT,
1010
PersonId BIGINT NOT NULL,
1111
CONSTRAINT PK_PersonSettings PRIMARY KEY (Id),
12-
CONSTRAINT FK_PersonSettings_PersonId FOREIGN KEY (PersonId) REFERENCES Person(Id) ON DELETE CASCADE
12+
CONSTRAINT FK_PersonSettings_PersonId FOREIGN KEY (PersonId) REFERENCES person(Id) ON DELETE CASCADE
1313
);
1414

15-
CREATE TABLE NoArgsEntity (
15+
CREATE TABLE noargsentity (
1616
Id BIGINT AUTO_INCREMENT,
1717
Value NVARCHAR(20),
1818
CONSTRAINT PK_NoArgsEntity PRIMARY KEY (Id)
1919
);
2020

21-
CREATE TABLE TransientEntity (
21+
CREATE TABLE transiententity (
2222
Id BIGINT AUTO_INCREMENT,
2323
Value NVARCHAR(20),
2424
CONSTRAINT PK_TransientEntity PRIMARY KEY (Id)
2525
);
2626

27-
CREATE TABLE PagingEntity (
27+
CREATE TABLE pagingentity (
2828
Id BIGINT AUTO_INCREMENT,
2929
Value NVARCHAR(20),
3030
CONSTRAINT PK_PagingEntity PRIMARY KEY (Id)

0 commit comments

Comments
 (0)