Skip to content
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

.throwOnError() doesn #1291

Closed
DavDeDev opened this issue Oct 21, 2024 · 1 comment
Closed

.throwOnError() doesn #1291

DavDeDev opened this issue Oct 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@DavDeDev
Copy link

DavDeDev commented Oct 21, 2024

Bug report

Describe the bug

According to #92 .throwOnError() should work as if I were typing something like:

	const { data: queryResult, error: queryError } = await supabase
		.from("cohorts")
		.select("id")
		.single();

	if (queryError) {
		throw queryError;
	}
	const thisHasTypeId = queryResult; // This is of type { id: number } NOT NULL!!

In the above case thisHasTypeId is of type {id:number}, but if I try to use .throwOnError():

	const { data: queryResult, error: queryError } = await supabase
		.from("cohorts")
		.select("id")
		.single()
		.throwOnError();


	const thisHasTypeNullToo = queryResult; // This is of type { id: number } | null, WHY NULL??

But here thisHasTypeNullToo has null too! so I would have to do type check as well

Expected behavior

It would be nice if the returned data didn't include the null type when using .throwOnError().

@DavDeDev DavDeDev added the bug Something isn't working label Oct 21, 2024
@DavDeDev
Copy link
Author

I will move it to supabase/postgres-js pardon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant