Domcario
01/16/2023, 1:17 AMraw PostgREST syntax
the docs mention for .or() method
getting a 22P02
error with message "invalid input syntax for type uuid: \"($user_id\""
js
const fetchEvents = async (user_id) => {
// filter for owner = user_id OR members (array column) contains user_id
const { data, error } = await supabase
.from('events')
.select()
.or('owner.eq.($user_id),members.cs.({$user_id})')
if (error) {
console.log('error: ', error);
}
else {
console.log('{data}: ', data);
}
}
Seth
01/16/2023, 1:27 AMdav
01/16/2023, 2:20 AMvarcharles
01/16/2023, 2:25 AMid(uuid) | title | content | owner
Users
id(uuid) | name | email
where owner in Posts uses the id in Users
Running this query,
.from('posts')
.select(`id, owner(email)`)
Returns this result
{ id: '1d289ad3-271b-4558-8b43-2db6365gabe3', owner: null }
Am I missing something?
Thanks!user8923
01/16/2023, 3:38 AMCREATE TABLE public.profile
(
user_id uuid NOT NULL,
email text NOT NULL,
"firstName" text,
"lastName" text,
is_sso_user boolean NOT NULL generated always as (false) stored
);
ALTER TABLE ONLY public.profile
ADD CONSTRAINT profile_pkey PRIMARY KEY (user_id);
ALTER TABLE ONLY public.profile
ADD CONSTRAINT profile_unique_email UNIQUE (email, is_sso_user);
ALTER TABLE ONLY public.profile
ADD CONSTRAINT profile_fkey_user_id FOREIGN KEY (user_id) REFERENCES auth.users(id);
-- why is this not working?
ALTER TABLE ONLY public.profile
ADD CONSTRAINT profile_fkey_email FOREIGN KEY (email, is_sso_user) REFERENCES auth.users(email, is_sso_user);
jinsley8
01/16/2023, 6:33 AMAdrianMsM91 {KBL}
01/16/2023, 8:12 AMMurkrage
01/16/2023, 9:58 AMjdgamble555
01/16/2023, 11:51 AMFloky Huan
01/16/2023, 2:14 PMsalzar
01/16/2023, 4:12 PM500
Invalid URL
at URL.onParseError (node:internal/url:565:9)
at new URL (node:internal/url:645:5)
at new SupabaseClient (C:\Users\User\Documents\Playground\Nuxt\supabase-nuxt-demo\node_modules\@supabase\supabase-js\dist\module\SupabaseClient.js:77:41)
at Module.createClient (C:\Users\User\Documents\Playground\Nuxt\supabase-nuxt-demo\node_modules\@supabase\supabase-js\dist\module\index.js:20:12)
at Module.useSupabaseAuthClient (C:\Users\User\Documents\Playground\Nuxt\supabase-nuxt-demo\node_modules\@nuxtjs\supabase\dist\runtime\composables\useSupabaseAuthClient.mjs:16:57)
at C:\Users\User\Documents\Playground\Nuxt\supabase-nuxt-demo\node_modules\@nuxtjs\supabase\dist\runtime\plugins\supabase.server.mjs:14:44
at fn (C:\Users\User\Documents\Playground\Nuxt\supabase-nuxt-demo\node_modules\nuxt\dist\app\nuxt.mjs:151:27)
at Object.callAsync (/C:/Users/User/Documents/Playground/Nuxt/supabase-nuxt-demo/node_modules/unctx/dist/index.mjs:49:19)
at callWithNuxt (C:\Users\User\Documents\Playground\Nuxt\supabase-nuxt-demo\node_modules\nuxt\dist\app\nuxt.mjs:153:23)
MDobs
01/16/2023, 4:18 PMfrom origin 'https://zb3yqn.csb.app' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Request URL: https://gwcjylrsyylsuacdrnov.supabase.co/realtime/v1/websocket?apikey=xxxx&eventsPerSecond=10&vsn=1.0.0
Request Method: GET
Status Code: 500
URL and API key are correct because the database does get updated with values.MaxAryus
01/16/2023, 4:39 PMdev Joakim Pedersen
01/16/2023, 4:51 PMCREATE OR REPLACE FUNCTION get_length(store_id integer)
RETURNS integer as $func$
SELECT COUNT(*)
FROM product_table where product_table.store_id = store_id and product_table.published = true
$func$
language sql;
It return success.
And I call it like so
export const getProductsLength = async (store_id: number) => {
let { data, error } = await supabase.rpc("get_length", {
store_id: store_id
})
if (error) throw error
return data
}
I've made sure that it get's a id passed in. 167 in my case. and that should return 39.
But it does return undefined.
Any ideas?dmorfav
01/16/2023, 5:22 PMOberstKlinck
01/16/2023, 5:31 PMDYELbrah
01/16/2023, 5:37 PMsupabase db push
Will the changes be captured on the remote db? Or will only NEW migration files be applied, thus old migration files ignored?DYELbrah
01/16/2023, 5:52 PMsupabase db remote commit
when we first started the project.
I believe we wanted to make sure any default settings were captured in our migration files, but are not sure if this was a good idea. The file contains a bunch of SQL code such as:
--
-- PostgreSQL database dump
--
-- Dumped from database version 14.1
-- Dumped by pg_dump version 14.5 (Debian 14.5-2.pgdg110+2)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: pgsodium; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "pgsodium" WITH SCHEMA "pgsodium";
--
-- Name: pg_graphql; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "pg_graphql" WITH SCHEMA "graphql";
--
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "pg_stat_statements" WITH SCHEMA "extensions";
--
-- Name: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "pgcrypto" WITH SCHEMA "extensions";
There's much more included... that's just a snippet.
Thanks!a guy
01/16/2023, 7:32 PMCaptCuddleFish
01/16/2023, 7:44 PManggoran
01/17/2023, 12:47 AMdraco
01/17/2023, 1:01 AMraise log
called in a function. Am I missing something simple?
Everything in the docs point to a UI that doesn't exist(https://supabase.com/docs/guides/platform/logs). I have also gone through the ui and clicked into the logs
menu and have spent a lot of time going through the results but never seem to find anything I output from a function.
I know the function is being called since most of the actions in it go through but I can't find any info from using either raise notice
or raise log
.
The real problem is using the function as a trigger to insert data into a table but it fails constantly with a relation does not exist
but the table I made has no relations to another table and it definitely exists since I can insert data into it, just not from a trigger function so I want to log out the data I am using to make sure it's not broken somehow.
Please help. I literally have no more manual to read and am officially lost.salzar
01/17/2023, 1:36 AMnahtnam
01/17/2023, 2:06 AMToken has expired or is invalid
and then if I refresh again and try again, it works. Is there any way to make it work the first time around? Attached what the network tab looks like when the account doesnt exist vs when it does existCody
01/17/2023, 2:42 AMsupabase link -p <password> --project-ref <project-ref>
the command will freeze for a long while and then eventually come back with
Error: Get "https://api.supabase.io/v1/projects/<project-ref>/postgrest": context canceled
I've been connecting directly to my hosted supabase project and am wanting to move my development to my local machine. So I'm trying to link the project so that I can grab the database schema using supabase db remote commit
.
Anyone have any advice? Maybe I can just update the local supabase/config.toml
file with my project ref? I don't see an obvious place to enter it in.
Thanks!mendrinos
01/17/2023, 4:33 AMjinsley8
01/17/2023, 5:18 AMUsers
have an id
, eth_address
while Assets
have id
, owner
, owner_id
.
When adding a new asset I will know the owner
(which matches to eth_address
in the Users table) but not the owner_id
. Is there anyway to lookup the User whose eth_address
matches the owner
then link their id
to the owner_id
?
Or should I just be making the owner
column reference eth_address
directly and get rid of the owner_id
altogether?
sql
-- USERS
CREATE TABLE if not exists public.users (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
eth_address character varying NOT NULL,
created_at timestamp with time zone DEFAULT timezone('utc'::text, now()) NOT NULL
);
comment on table public.users is 'All active users';
sql
-- ASSETS
CREATE TABLE if not exists public.assets (
id bigint generated always as identity PRIMARY KEY,
owner_id uuid references public.users NOT NULL,
owner character varying NOT NULL,
created_at timestamp with time zone DEFAULT timezone('utc'::text, now()) NOT NULL
);
0xRaduan
01/17/2023, 6:26 AMcodeless_tinker_bot
01/17/2023, 7:26 AMAntDX316
01/17/2023, 8:19 AM