Skip to content

Commit

Permalink
[Bugfix/BE] DatabaseCleanup SQL 생성 방식 변경 (#687)
Browse files Browse the repository at this point in the history
* [BE] 스프린트5에 대한 버퍼를 진행한다 (#678)

* [BE] 스프린트5에 대한 버퍼를 진행한다 (#677)

* refactor: 팔로잉된 회원의 아이디를 목록으로 가져올 때 조인하지 않도록 변경

* refactor: 회원을 조회할 때 검색된 결과가 없다면, 다음 로직이 일어나지 않도록 변경

* refactor: findByContains 메서드 명 변경

* test: MemberServiceTest 한글 메서드 명 변경

* [BE] DatabaseCleanup sql 생성 방식 변경 (#685)

test: DatabaseCleanup sql 생성 방식 변경
  • Loading branch information
yh20studio authored Sep 29, 2022
1 parent 3a2b5ba commit e3783b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.woowacourse.f12.acceptance.support;

import static com.woowacourse.f12.acceptance.support.EscapeSqlUtil.escapeTableName;

import java.util.List;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
Expand Down Expand Up @@ -31,8 +33,9 @@ public void execute() {
entityManager.flush();
entityManager.createNativeQuery("SET REFERENTIAL_INTEGRITY FALSE").executeUpdate();
for (String tableName : tableNames) {
entityManager.createNativeQuery("TRUNCATE TABLE " + tableName).executeUpdate();
entityManager.createNativeQuery("ALTER TABLE " + tableName + " ALTER COLUMN ID RESTART WITH 1")
entityManager.createNativeQuery("TRUNCATE TABLE " + escapeTableName(tableName)).executeUpdate();
entityManager.createNativeQuery(
"ALTER TABLE " + escapeTableName(tableName) + " ALTER COLUMN ID RESTART WITH 1")
.executeUpdate();
}
entityManager.createNativeQuery("SET REFERENTIAL_INTEGRITY TRUE").executeUpdate();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.woowacourse.f12.acceptance.support;

public class EscapeSqlUtil {

public static String escapeTableName(String tableName) {
if (tableName == null) {
return null;
}
return tableName.replace(" ", "")
.replace(";", "");
}
}

0 comments on commit e3783b7

Please sign in to comment.