Merge pull request 'fix(테이블타입): constraints API PgArray 디코딩 + primary_key key 매칭' (#15) from johngreen into main
Build & Deploy to K8s / build-and-deploy (push) Successful in 8m29s
Build & Deploy to K8s / build-and-deploy (push) Successful in 8m29s
This commit was merged in pull request #15.
This commit is contained in:
@@ -10,6 +10,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -941,6 +942,20 @@ public class TableManagementService extends BaseService {
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<String> parseColumnArray(Object cols) {
|
||||
if (cols instanceof List) return (List<String>) cols;
|
||||
if (cols instanceof java.sql.Array arr) {
|
||||
try {
|
||||
Object raw = arr.getArray();
|
||||
if (raw instanceof Object[] arrObj) {
|
||||
return Arrays.stream(arrObj)
|
||||
.filter(Objects::nonNull)
|
||||
.map(Object::toString)
|
||||
.filter(s -> !s.isBlank())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.warn("parseColumnArray: java.sql.Array decode 실패 — fallback", e);
|
||||
}
|
||||
}
|
||||
if (cols instanceof String s) {
|
||||
return Arrays.stream(s.replace("{", "").replace("}", "").split(","))
|
||||
.filter(c -> !c.isBlank())
|
||||
|
||||
@@ -381,7 +381,7 @@ export default function TableManagementPage() {
|
||||
if (response.data.success) {
|
||||
const data = response.data.data;
|
||||
setConstraints({
|
||||
primaryKey: data.primaryKey ?? { name: "", columns: [] },
|
||||
primaryKey: data.primary_key ?? { name: "", columns: [] },
|
||||
indexes: data.indexes ?? [],
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user