-
Notifications
You must be signed in to change notification settings - Fork 3
[fix] neon lazy init 적용 #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,15 @@ | ||
| import { vi } from "vitest"; | ||
|
|
||
| // 테스트 환경(jsdom)에서는 실제 DB 연결이 없으므로 | ||
| // @/shared/db 모듈 전체를 가짜(mock)로 대체합니다. | ||
| // 각 테스트 파일에서 vi.mocked(db.insert).mockResolvedValue(...) 등으로 | ||
| // 원하는 반환값을 설정할 수 있습니다. | ||
| vi.mock("@/shared/db", () => ({ | ||
| db: { | ||
| query: {}, | ||
| insert: vi.fn(), | ||
| update: vi.fn(), | ||
| delete: vi.fn(), | ||
| select: vi.fn(), | ||
| }, | ||
| })); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Proxy에
get트랩만 구현되어 있어 일부 연산에서 예기치 않은 동작 가능현재 Proxy는
get트랩만 구현되어 있습니다. 대부분의 DB 사용 케이스(db.query,db.insert등)에서는 문제없지만, 다음과 같은 코드가 있으면 의도와 다르게 동작합니다:'query' in db→ 항상false(빈 객체 기준)Object.keys(db)→ 빈 배열 반환현재 코드베이스에서 이런 패턴이 없다면 문제없지만, 필요시 추가 트랩을 구현할 수 있습니다.
🔧 더 완전한 Proxy 구현 (필요시)
export const db = new Proxy({} as DB, { get(_, prop) { return getDb()[prop as keyof DB]; }, + has(_, prop) { + return prop in getDb(); + }, + ownKeys() { + return Reflect.ownKeys(getDb()); + }, + getOwnPropertyDescriptor(_, prop) { + return Object.getOwnPropertyDescriptor(getDb(), prop); + }, });🤖 Prompt for AI Agents