Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 9cc75db

Browse files
committed
fix: csv bug and type error
1 parent cf87f46 commit 9cc75db

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/lib/PostgrestTransformBuilder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ export default class PostgrestTransformBuilder<T> extends PostgrestBuilder<T> {
123123
/**
124124
* Set the response type to CSV.
125125
*/
126-
csv(): this {
126+
csv(): PromiseLike<PostgrestSingleResponse<string>> {
127127
this.headers['Accept'] = 'text/csv'
128-
return this
128+
return this as PromiseLike<PostgrestSingleResponse<string>>
129129
}
130130
}

src/lib/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@ export abstract class PostgrestBuilder<T> implements PromiseLike<PostgrestRespon
104104
const isReturnMinimal = this.headers['Prefer']?.split(',').includes('return=minimal')
105105
if (this.method !== 'HEAD' && !isReturnMinimal) {
106106
const text = await res.text()
107-
if (text && text !== '' && this.headers['Accept'] !== 'text/csv')
107+
if (!text) {
108+
// discard `text`
109+
} else if (this.headers['Accept'] === 'text/csv') {
110+
data = text
111+
} else {
108112
data = JSON.parse(text)
113+
}
109114
}
110115

111116
const countHeader = this.headers['Prefer']?.match(/count=(exact|planned|estimated)/)

0 commit comments

Comments
 (0)