supalite 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -289,7 +289,7 @@ const { data, error } = await client
|
|
|
289
289
|
- `is(column, value)`: IS 연산자
|
|
290
290
|
- `not(column, operator, value)`: Negates an operator (e.g., `not('column', 'is', null)`).
|
|
291
291
|
- `contains(column, value)`: 배열/JSON 포함 여부
|
|
292
|
-
- `or(conditions)`: OR 조건 (예: 'status.eq.active,role.eq.admin')
|
|
292
|
+
- `or(conditions)`: OR 조건 (예: 'status.eq.active,role.eq.admin', 'valid_until.is.null')
|
|
293
293
|
|
|
294
294
|
### 기타 메소드
|
|
295
295
|
|
package/dist/query-builder.js
CHANGED
|
@@ -171,7 +171,7 @@ class QueryBuilder {
|
|
|
171
171
|
or(conditions) {
|
|
172
172
|
const orParts = conditions.split(',').map(condition => {
|
|
173
173
|
const [field, op, value] = condition.split('.');
|
|
174
|
-
const validOperators = ['eq', 'neq', 'ilike', 'like', 'gt', 'gte', 'lt', 'lte'];
|
|
174
|
+
const validOperators = ['eq', 'neq', 'ilike', 'like', 'gt', 'gte', 'lt', 'lte', 'is'];
|
|
175
175
|
if (!validOperators.includes(op)) {
|
|
176
176
|
throw new Error(`Invalid operator: ${op}`);
|
|
177
177
|
}
|
|
@@ -204,6 +204,13 @@ class QueryBuilder {
|
|
|
204
204
|
return `"${field}" < $${paramIndex}`;
|
|
205
205
|
case 'lte':
|
|
206
206
|
return `"${field}" <= $${paramIndex}`;
|
|
207
|
+
case 'is':
|
|
208
|
+
if (processedValue === null) {
|
|
209
|
+
// Remove the null value from whereValues since we don't need a parameter for IS NULL
|
|
210
|
+
this.whereValues.pop();
|
|
211
|
+
return `"${field}" IS NULL`;
|
|
212
|
+
}
|
|
213
|
+
return `"${field}" IS $${paramIndex}`;
|
|
207
214
|
default:
|
|
208
215
|
return '';
|
|
209
216
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# 변경 보고서: `or` 메소드 내 `is` 연산자 지원
|
|
2
|
+
|
|
3
|
+
**날짜:** 2025년 11월 21일
|
|
4
|
+
|
|
5
|
+
## 변경 유형
|
|
6
|
+
|
|
7
|
+
- [x] 기능 추가
|
|
8
|
+
- [ ] 버그 수정
|
|
9
|
+
- [ ] 성능 개선
|
|
10
|
+
- [ ] 문서 업데이트
|
|
11
|
+
- [ ] 기타
|
|
12
|
+
|
|
13
|
+
## 변경 내용
|
|
14
|
+
|
|
15
|
+
### `QueryBuilder`
|
|
16
|
+
|
|
17
|
+
- **`or` 메소드 개선**: `or` 메소드 내부에서 `is` 연산자를 사용할 수 있도록 지원을 추가했습니다. 이제 `valid_until.is.null`과 같은 표현을 통해 `IS NULL` 조건을 `OR` 절 안에서 사용할 수 있습니다.
|
|
18
|
+
|
|
19
|
+
**사용 예시:**
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
const { data } = await client
|
|
23
|
+
.from('credits')
|
|
24
|
+
.select('*')
|
|
25
|
+
.or('valid_until.is.null,valid_until.gt.now()');
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
위 코드는 `SELECT * FROM "public"."credits" WHERE ("valid_until" IS NULL OR "valid_until" > 'now()')` SQL 쿼리를 생성합니다.
|
|
29
|
+
|
|
30
|
+
## 관련 파일
|
|
31
|
+
|
|
32
|
+
- `src/query-builder.ts`
|
|
33
|
+
- `README.md`
|