Super Kawaii Cute Cat Kaoani
๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
{Troubleshooting}

[ํŠธ๋Ÿฌ๋ธ” ์ŠˆํŒ…] Prisma mode: "insensitive" ์˜ต์…˜์˜ MySQL ๋ฏธ์ง€์› ๋ฌธ์ œ

by wonee1 2025. 3. 3.
728x90

 

๐Ÿšจ ๋ฐœ์ƒํ•œ ๋ฌธ์ œ์™€ ์ƒํ™ฉ


 

 

mode: "insensitive" ์˜ต์…˜์ด Prisma์˜ ์ผ๋ถ€ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค(MySQL, PostgreSQL ๋“ฑ)์—์„œ ์ง€์›๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ

//ํŒ ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ (์ œ๋ชฉ, ๋‚ด์šฉ, ํ•ด์‹œํƒœ๊ทธ ํฌํ•จ)
  254 public async searchTips(query: string | null, hashtags: string[], skip: number, take: number, sort: string) {
→ 255   return await prisma.tip.findMany({
          where: {
            AND: [
              {
                OR: [
                  {
                    title: {
                      contains: "1",
                      mode: "insensitive"
                    }
                  },
                  {
                    content: {
                      contains: "1",
                      mode: "insensitive"
                    }
                  }
                ]
              },
              {
                hashtags: {
                  some: {
                    hashtag: {
                      name: {
                        in: [
                          "#์ฒญ์†Œ"
                        ]
                      }
                    }
                  }
                }
              }
            ]
          },
          skip: 0,
          take: 10,
          orderBy: {
            created_at: "desc"
          },
          include: {
            media: true,
            hashtags: {
              include: {
                hashtag: true
              }
            },
            user: {
              select: {
                user_id: true,
                nickname: true,
                profile_image_url: true
              }
            },
            likes: true,
            saves: true
          }
        })

Unknown argument mode. Did you mean lte? Available options are marked with ?.
    at xn (D:\\umc-h-master\\node_modules\\@prisma\\client\\runtime\\library.js:29:1363)
    at Bn.handleRequestError (D:\\umc-h-master\\node_modules\\@prisma\\client\\runtime\\library.js:121:7005)
    at Bn.handleAndLogRequestError (D:\\umc-h-master\\node_modules\\@prisma\\client\\runtime\\library.js:121:6686)
    at Bn.request (D:\\umc-h-master\\node_modules\\@prisma\\client\\runtime\\library.js:121:6393)    
    at async l (D:\\umc-h-master\\node_modules\\@prisma\\client\\runtime\\library.js:130:9645)       
    at TipRepository.searchTips (D:\\umc-h-master\\src\\repositories\\tip.repository.ts:255:12)    
    at TipService.searchTips (D:\\umc-h-master\\src\\services\\tip.service.ts:234:18)
    at TipController.searchTips (D:\\umc-h-master\\src\\controllers\\tip.controller.ts:823:22) {   
  clientVersion: '6.3.1'
}

 

 

 

๐Ÿค” ๋ฌธ์ œ์˜ ์›์ธ ํŒŒ์•…ํ•˜๊ธฐ


  • mode: "insensitive" ์˜ต์…˜์€ PostgreSQL์—์„œ๋งŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๋ฉฐ, MySQL์—์„œ๋Š” ์ง€์›๋˜์ง€ ์•Š์Œ.

 

๐Ÿ’กํ•ด๊ฒฐ์ฑ…: MySQL์—์„œ ๊ธฐ๋ณธ์ ์œผ๋กœ utf8_general_ci ๋˜๋Š” utf8mb4_general_ci ์ปฌ๋ ˆ์ด์…˜์„ ์‚ฌ์šฉํ•˜๋ฉด, ๋Œ€์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•˜์ง€ ์•Š๋Š” ๊ฒ€์ƒ‰์ด ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ์— Prisma์˜ ๊ธฐ๋ณธ ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ(contains)์„ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

 

 

 

๐Ÿƒ๐Ÿป‍โ™€๏ธ ์‹œ๋„ํ•ด๋ณธ ๋ฐฉ๋ฒ•


mode: "insensitive" ์˜ต์…˜์„ ์ œ๊ฑฐํ•˜๊ณ , ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ ์—†์ด ๊ฒ€์ƒ‰์ด ๊ฐ€๋Šฅํ•˜๋„๋ก Prisma ๊ธฐ๋ณธ ์„ค์ •์— ์˜์กดํ•˜๋„๋ก ์ฝ”๋“œ๋ฅผ ์ˆ˜์ •ํ•œ๋‹ค

  // โœ… ํŒ ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ (์ œ๋ชฉ, ๋‚ด์šฉ, ํ•ด์‹œํƒœ๊ทธ ํฌํ•จ)
  public async searchTips(query: string | null, hashtags: string[], skip: number, take: number, sort: string) {
    return await prisma.tip.findMany({
      where: {
        AND: [
          query
            ? {
                OR: [
                  { title: { contains: query } }, // โœ… `mode: "insensitive"` ์ œ๊ฑฐ
                  { content: { contains: query } }
                ],
              }
            : {}, // โœ… ๊ฒ€์ƒ‰์–ด๊ฐ€ ์—†์œผ๋ฉด ๋ฌด์‹œ
          hashtags.length > 0
            ? {
                hashtags: {
                  some: {
                    hashtag: {
                      name: { in: hashtags },
                    },
                  },
                },
              }
            : {}, // โœ… ํ•ด์‹œํƒœ๊ทธ๊ฐ€ ์—†์œผ๋ฉด ๋ฌด์‹œ
        ],
      },
      skip,
      take,
      orderBy: this.getSortOption(sort), // โœ… ์ •๋ ฌ ์˜ต์…˜ ์ ์šฉ
      include: {
        media: true,
        hashtags: { include: { hashtag: true } },
        user: { select: { user_id: true, nickname: true, profile_image_url: true } },
        likes: true,
        saves: true,
      },
    });
  }

 

 

 

โœ… ๊ฒฐ๋ก 


 

mode: "insensitive" ์ œ๊ฑฐ → MySQL์—์„œ๋Š” ์ง€์›๋˜์ง€ ์•Š์œผ๋ฏ€๋กœ ์‚ญ์ œ

728x90