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

Incorrect typescript types for nested embedding #837

Open
timbovelander opened this issue Apr 29, 2024 · 0 comments
Open

Incorrect typescript types for nested embedding #837

timbovelander opened this issue Apr 29, 2024 · 0 comments

Comments

@timbovelander
Copy link

timbovelander commented Apr 29, 2024

Describe the bug
The generated typescript types are incorrect when using nested embedding in a query. Gives the error:

`Property 'protertyName' does not exist on type 'SelectQueryError<"Referencing missing column 'propertyName'">[].`

To Reproduce
Steps to reproduce the behavior:

  1. Create 3 tables, one has a foreign keys to the each of the other 2 tables.
create table public.recipes (
  id bigint primary key generated always as identity,
  title text not null
);

create table public.ingredients (
  id bigint primary key generated always as identity,
  title text not null
);

create table public.recipe_ingredients (
  recipe bigint not null references recipes on update cascade on delete cascade,
  ingredient bigint not null references ingredients on update cascade,
  constraint recipe_ingredients_pkey primary key (one, two)
);
  1. Generate types using npx supabase gen types typescript --local > /some/path/types.ts
  2. Make a query using a client:
const recipe = await supabase
  .from("recipes")
  .select("title, recipe_ingredients(ingredient(title))")
  .eq("id", id)
  .maybeSingle();
  1. When trying to access the property, you get the error as mentioned above:
recipe.data.recipe_ingredients.map((recipe_ingredient) => recipe_ingredient.ingredient.title);

Expected behavior
I expected the type to be string.

Screenshots
image

System information
Rerun the failing command with --create-ticket flag.

  • Ticket ID: -
  • Version of OS: Ubuntu 22.04.4
  • Version of CLI: v1.163.6
  • Version of Docker: v26.1.0
  • Versions of services: [output from supabase services command]
       SERVICE IMAGE      │        LOCAL         │  LINKED
 ─────────────────────────┼──────────────────────┼────────────
   supabase/postgres      │ 15.1.1.41            │ 15.1.1.41
   supabase/gotrue        │ v2.148.0             │ v2.148.0
   postgrest/postgrest    │ v12.0.2              │ v12.0.2
   supabase/realtime      │ v2.28.32             │ -
   supabase/storage-api   │ v1.0.10              │ v1.0.10
   supabase/edge-runtime  │ v1.45.2              │ -
   supabase/studio        │ 20240422-5cf8f30     │ -
   supabase/postgres-meta │ v0.80.0              │ -
   supabase/logflare      │ 1.4.0                │ -
   bitnami/pgbouncer      │ 1.20.1-debian-11-r39 │ -
   darthsim/imgproxy      │ v3.8.0               │ -

Additional context
If applicable, add any other context about the problem here.

  • Version of @supabase/ssr v0.3.0
  • Version of Node.js v20.11.0
@sweatybridge sweatybridge transferred this issue from supabase/cli Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant