-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sqlserver): prevent cast from NVARCHAR to VARCHAR
Related: #158
- Loading branch information
1 parent
326d1e8
commit f1e0ecd
Showing
8 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
services: | ||
postgres: | ||
image: postgres:14 | ||
ports: | ||
- 5432:5432 | ||
environment: | ||
POSTGRES_PASSWORD: "postgres" | ||
|
||
sqlserver: | ||
image: mcr.microsoft.com/mssql/server:2022-preview-ubuntu-22.04 | ||
ports: | ||
- 1433:1433 | ||
environment: | ||
ACCEPT_EULA: Y | ||
MSSQL_SA_PASSWORD: "Changeit_123" | ||
|
||
mysql: | ||
image: mysql:5.7 | ||
ports: | ||
- 3306:3306 | ||
environment: | ||
MYSQL_DATABASE: test | ||
MYSQL_ROOT_PASSWORD: changeit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/test/java/org/springframework/data/jpa/datatables/repository/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.springframework.data.jpa.datatables.repository; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import lombok.Data; | ||
import org.hibernate.annotations.Nationalized; | ||
|
||
@Entity | ||
@Data | ||
@Table(name = "users") | ||
public class User { | ||
|
||
@Id long id; | ||
@Nationalized String name; | ||
|
||
public User() { | ||
} | ||
|
||
public User(long id, String name) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/test/java/org/springframework/data/jpa/datatables/repository/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.springframework.data.jpa.datatables.repository; | ||
|
||
public interface UserRepository extends DataTablesRepository<User, Long> { | ||
} |
43 changes: 43 additions & 0 deletions
43
src/test/java/org/springframework/data/jpa/datatables/repository/UserRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.springframework.data.jpa.datatables.repository; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.data.jpa.datatables.Config; | ||
import org.springframework.data.jpa.datatables.mapping.DataTablesInput; | ||
import org.springframework.data.jpa.datatables.mapping.DataTablesOutput; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit.jupiter.DisabledIf; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@ExtendWith(SpringExtension.class) | ||
@ContextConfiguration(classes = Config.class) | ||
public class UserRepositoryTest { | ||
|
||
@Autowired private UserRepository userRepository; | ||
|
||
private void init() { | ||
userRepository.save(new User(1L, "r")); | ||
userRepository.save(new User(2L, "ř")); | ||
userRepository.save(new User(3L, "ŗ")); | ||
userRepository.save(new User(4L, "ɍ")); | ||
userRepository.save(new User(5L, "ȓ")); | ||
} | ||
|
||
@Test | ||
@DisabledIf(value = "#{'${spring.profiles.active}' == 'mysql'}", loadContext = true) | ||
void withNationalizedColumn() { | ||
init(); | ||
|
||
DataTablesInput input = new DataTablesInput(); | ||
input.addColumn("name", true, true, "ř"); | ||
|
||
DataTablesOutput<User> output = userRepository.findAll(input); | ||
|
||
assertThat(output.getRecordsFiltered()).isEqualTo(1); | ||
assertThat(output.getData().get(0).getId()).isEqualTo(2L); | ||
} | ||
|
||
} |