postgrest-swift icon indicating copy to clipboard operation
postgrest-swift copied to clipboard

Added select with foreign table

Open DominatorVbN opened this issue 2 years ago • 3 comments

What kind of change does this PR introduce?

This PR introduce capability to query foreign tables using select

What is the current behavior?

Current api does not support querying foreign table like JS version https://supabase.com/docs/reference/javascript/select?example=query-foreign-tables

What is the new behavior?

New API would enable configuring the query to fetch foreign tables similar to JS SDK

Additional context

NA

DominatorVbN avatar Oct 08 '23 16:10 DominatorVbN

Hi @DominatorVbN I think the current implementation is already capable of querying foreign tables, and rewriting the JS example you mentioned in Swift, it should be as follows and work as expected.

let response = try await client
  .database
  .from("countries")
  .select(columns: "name,cities(name)")
  .execute()
  .value

Can you try that within your project and let me know the result?

grdsdev avatar Oct 09 '23 14:10 grdsdev

Hi @DominatorVbN I think the current implementation is already capable of querying foreign tables, and rewriting the JS example you mentioned in Swift, it should be as follows and work as expected.

let response = try await client
  .database
  .from("countries")
  .select(columns: "name,cities(name)")
  .execute()
  .value

Can you try that within your project and let me know the result?

Hey, Though this works, this seems like a bit too stringly typed API, can we may be try to alter it in direction where we could maybe write this query using more builder and less string format, which this PR can be a pert of, may be the implementation of the PR might not be optimal, but would like to have discussion around this.

DominatorVbN avatar Oct 18 '23 18:10 DominatorVbN

I agree with @DominatorVbN here. The syntax to grab foreign tables seems off here. There should be a more ergonomic way.

SergioB-dev avatar Aug 18 '24 21:08 SergioB-dev