Skip to content

Order on a foreign table #971

@bllakcn

Description

@bllakcn

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

Hey guys, I am not an expert around here but hear me out :)

Based on docs here on how to order the query result on a referenced table .

const { data, error } = await supabase
  .from('countries')
  .select(`
    name,
    cities (
      name
    )
  `)
  .order('name', { referencedTable: 'cities', ascending: false })

First issue is that, maybe the docs is outdated but, this options key is called foreignTable in the supabase-js package 2.38.3.

Secondly, when i add foreignTable option to order the foreign table that comes with the query, in Typescript, I am given the columns of the base table of the query (countries in this example) as autocomplete. Though, I can still use the desired column name as the order value and TS will not yell about it.

Expected behavior

If I want to order the foreign table and add that option key, TS should recognize that so I should be able to use the columns of that table to order. The inferred type is still the columns of the base table.

System information

  • Version of supabase-js: [2.38.3]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions