Comments (6)
You can workaround for this issue using foreign table reference same as in select method
const { data, error } = await supabase
.from('countries')
.select(`
name,
cities (
name
)
`)
.order('cities(name)', { ascending: false })
from supabase-js.
This requires PostgREST v11.
To force update remote supabase you need to pause it and restore it.
To update local supabase, update supabase-cli and restart whole supabase using stop
and start
from supabase-js.
You can workaround for this issue using foreign table reference same as in select method
const { data, error } = await supabase .from('countries') .select(` name, cities ( name ) `) .order('cities(name)', { ascending: false })
When I try this I get the following Postgres error:
{
code: 'PGRST100',
details: `unexpected '(' expecting letter, digit, "-", "->>", "->", delimiter (.), "," or end of input`,
hint: null,
message: '"failed to parse order (product_category(name).desc)" (line 1, column 17)'
}
This is my specific query:
const {data, error} = await supabase.from("product").select("id, product_category(name)").order("product_category(name)", { ascending: false })
Any idea how to work around this?
from supabase-js.
I had to change the structure of my relations a bit, so now I have a many-to-many relationship between my products and my product categories. I created a separate table fot this called product_to_product_category
.
I was hoping that I could still order by the name
value but unfortunately it doesn't work with the following call:
const {data, error} = await supabase
.from("product")
.select("id, product_to_product_category(product_category(name, primary))")
.order("name", { ascending: false, referencedTable: product_to_product_category.product_category })
Is there any way to make this work?
from supabase-js.
Hi, I have been unable to get order
with a referencedTable
to affect the results of the parent table. In other words, these docs have been untrue for me. Others have hit this too.
FWIW @KajSzy 's workaround is working for me.
I wanted to get clarity on this open issue. Is it related to the functionality of ordering with referencedTable
, or Typescript typing errors? If it's just typing, should I open a separate issue? Thanks.
from supabase-js.
Facing the same issue. Using referenceTable
isn't working.
const {data, error} = await supabase
.from('haikus')
.select(
'id, content, created_at, profiles(id, username, avatar_path), likes!inner()'
)
.eq('likes.profile_id', userId)
.order('created_at', { referencedTable: 'likes', ascending: false });
You can workaround for this issue using foreign table reference same as in select method
const { data, error } = await supabase .from('countries') .select(` name, cities ( name ) `) .order('cities(name)', { ascending: false })
Tried doing this, but I got an error:
const {data, error} = await supabase
.from('haikus')
.select(
'id, content, created_at, profiles(id, username, avatar_path), likes!inner()'
)
.eq('likes.profile_id', userId)
.order('likes(created_at)', { ascending: false });
{
code: 'PGRST118';
details: "'haikus' and 'likes' do not form a many-to-one or one-to-one relationship";
hint: null;
message: "A related order on 'likes' is not possible";
}
from supabase-js.
Related Issues (20)
- `supabase.createClient` not reading in access token from URL and initialising session object when using Google or Github sign in. HOT 1
- Selecting a schema on createClient does not work HOT 2
- supabase.auth.getSession is slow HOT 2
- Return format is not consistent across queries with the same select parameters HOT 1
- Version v2.39.2 and above break types HOT 4
- Bug/Proposal: try catch not working on supabase api functions HOT 1
- Deploy Svelte and Supabase to Google cloud and supabase is unable to get the environment variables HOT 1
- Twitter OAuth stopped working
- supabase stop --no-backup doesn't delete backup
- `GoTrueClient` Memory Leak HOT 1
- docs: clarify if client supports retry HOT 1
- Cloudflare Block for Incoming Webhooks - Edge Functions
- TS `ParserError` for spread operation in `select`
- Newly added column doesn't exist on update, but when I fetch, it's visible HOT 1
- docs: improve py create a new user HOT 1
- Enabling Post-Signup Email Verification without Blocking User Sign-In on Supabase (Resend) HOT 5
- Nextjs14 with Supabase Auth - AuthApiError: invalid claim: missing sub claim HOT 23
- Max rows in API Settings doesn't work on local development
- chore(deps): Update postgrest-js version to 1.13.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from supabase-js.