테스트 프로젝트 테이블 생성 및 오류들 수정

This commit is contained in:
kjs
2025-09-19 12:19:34 +09:00
parent eb6fa71cf4
commit d1e1c7964b
28 changed files with 2221 additions and 94 deletions

View File

@@ -549,7 +549,7 @@ export class DynamicFormService {
* 폼 데이터 업데이트 (실제 테이블에서 직접 업데이트)
*/
async updateFormData(
id: number,
id: string | number,
tableName: string,
data: Record<string, any>
): Promise<FormDataResult> {
@@ -642,10 +642,36 @@ export class DynamicFormService {
const primaryKeyColumn = primaryKeys[0]; // 첫 번째 기본키 사용
console.log(`🔑 테이블 ${tableName}의 기본키: ${primaryKeyColumn}`);
// 기본키 데이터 타입 조회하여 적절한 캐스팅 적용
const primaryKeyInfo = (await prisma.$queryRawUnsafe(`
SELECT data_type
FROM information_schema.columns
WHERE table_name = '${tableName}'
AND column_name = '${primaryKeyColumn}'
AND table_schema = 'public'
`)) as any[];
let typeCastSuffix = "";
if (primaryKeyInfo.length > 0) {
const dataType = primaryKeyInfo[0].data_type;
console.log(`🔍 기본키 ${primaryKeyColumn}의 데이터 타입: ${dataType}`);
if (dataType.includes("character") || dataType.includes("text")) {
typeCastSuffix = "::text";
} else if (dataType.includes("bigint")) {
typeCastSuffix = "::bigint";
} else if (
dataType.includes("integer") ||
dataType.includes("numeric")
) {
typeCastSuffix = "::numeric";
}
}
const updateQuery = `
UPDATE ${tableName}
SET ${setClause}
WHERE ${primaryKeyColumn} = $${values.length}
WHERE ${primaryKeyColumn} = $${values.length}${typeCastSuffix}
RETURNING *
`;
@@ -707,7 +733,7 @@ export class DynamicFormService {
* 폼 데이터 삭제 (실제 테이블에서 직접 삭제)
*/
async deleteFormData(
id: number,
id: string | number,
tableName: string,
companyCode?: string
): Promise<void> {