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

Bug: TypeScript type inference allows null for !inner join results in supabase-js v2.48.1 #1368

Open
2 tasks done
rhslvkf opened this issue Feb 20, 2025 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@rhslvkf
Copy link

rhslvkf commented Feb 20, 2025

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

In supabase-js v2.48.1, when using the !inner keyword for inner joins, the TypeScript type inference incorrectly includes null in the return type. This is logically incorrect since inner joins by definition cannot return null values. This regression was introduced in v2.48.1, as it worked correctly in v2.47.5.

To Reproduce

Steps to reproduce the behavior:

  1. Install supabase-js v2.48.1
npm install @supabase/[email protected]
  1. Create a query with an inner join:
const result = await supabase
  .from('table1')
  .select('field!inner(table2)')

// TypeScript infers result type as { field: object | null }
// This is incorrect as inner join cannot return null
  1. Compare with v2.47.5 where the type is correctly inferred without null

Expected behavior

When using !inner for joins, the TypeScript type system should not include null in the return type, as inner joins by definition cannot return null values.

System information

  • Version of supabase-js: 2.48.1
  • Version of Node.js: Latest LTS

Additional context

The issue appears to be related to type definition changes between v2.47.5 and v2.48.1. In v2.47.5, the type definition correctly handled inner joins with the inner: true property, while v2.48.1 changed this to innerJoin: true and added additional type checks that incorrectly allow for null values.

Previous working implementation (v2.47.5):

[{ name: Name; original: Name; children: Fields; inner: true }, EatWhitespace<Remainder>]

Current implementation with issue (v2.48.1):

[{ type: 'field'; name: Name; innerJoin: true; children: Children }, Remainder]

This appears to be an unintended side effect of the type system changes in v2.48.1.

@rhslvkf rhslvkf added the bug Something isn't working label Feb 20, 2025
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