KiwiHour
05/13/2023, 9:39 PMjarnold
05/13/2023, 10:09 PMSELECT * FROM pg_publication_tables WHERE tablename = 'layers_properties';
Results in:
| pubname | schemaname | tablename | attnames | rowfilter |
| ----------------- | ---------- | ----------------- | --------------------------------------- | --------- |
| supabase_realtime | public | layers_properties | {owner_id,layer_id,property_name,value} |
|KiwiHour
05/13/2023, 10:44 PMKiwiHour
05/13/2023, 11:05 PMrecipies
that contains the user_id
that crated it.
I also have a junction table xref_recipe_ingredients
which contains the recipe_id
and ingredient_id
which are both foreign keys
However, I want an RLS conditional expression on this junction table to make sure that the user adding this new relation is the owner of the recipe
So, how would I use the foreign key recipe_id
to obtain the user_id
of that specific recipe in a SQL conditional expression?
If my explanation is unclear I can add some images which may helpcaseycrogers
05/14/2023, 12:17 AMMobileMon
05/14/2023, 1:17 AMvandivier
05/14/2023, 1:24 AMshnoman
05/14/2023, 2:43 AMsilentworks
05/14/2023, 12:05 PMEKI
05/14/2023, 3:10 AMrendom
05/14/2023, 3:37 AMetdev2
05/14/2023, 4:53 AMoctalpixel
05/14/2023, 5:41 AMCokaps016
05/14/2023, 5:47 AMconsole.log(supabase)
print a bunch of info however console.log(data)
just doesn't work
Here is content of my routes/+page.server.js
js
import { supabase } from '$lib/supabaseClient';
export async function load() {
console.log(supabase);
const { data: data, error } = await supabase.from('tara').select('*');
console.log(data); // Nothing
};
}
and +page.svelte
(under script tag)
js
<script>
...
export let data;
let { tData } = data;
$: ({ tData } = data);
console.log('This is data');
console.log(tData);
</script>
But the result when I run pnpm dev
in the console show an empty array which makes me really confused. Any ideas on fixing this issue. Thanks
https://cdn.discordapp.com/attachments/1107182476910141570/1107182477073711165/image.png▾
https://cdn.discordapp.com/attachments/1107182476910141570/1107182477363138601/image.png▾
ccssmnn
05/14/2023, 10:46 AMhttps://cdn.discordapp.com/attachments/1107257745394126960/1107257745616420924/Screenshot_2023-05-14_at_12.42.37.png▾
niqqa bird
05/14/2023, 11:07 AMexport const query = async (query) => {
const vectorStore = await SupabaseVectorStore.fromExistingIndex(
new OpenAIEmbeddings(),
{
client: SUPABASE_CLIENT,
tableName: 'documents',
queryName: 'match_documents_with_filters',
}
);
const chain = ConversationalRetrievalQAChain.fromLLM(
model,
vectorStore.asRetriever(null, {
email: 'abc@gmail.com',
}),
{ returnSourceDocuments: true }
);
const res = await chain.call({
question: query,
chat_history: [],
});
console.log(res.text);
console.log({ docs: res.sourceDocuments });
return res;
};
query('what is my name?');
CREATE FUNCTION match_documents_with_filters (
query_embedding vector(1536),
match_count int,
filter jsonb DEFAULT '{}'
) RETURNS TABLE (
id bigint,
content text,
metadata jsonb,
similarity float
)
LANGUAGE plpgsql
AS $$
#variable_conflict use_column
BEGIN
RETURN QUERY
SELECT
id,
content,
metadata,
1 - (documents.embedding <=> query_embedding) as similarity
FROM
documents
WHERE
metadata @> filter
ORDER BY
documents.embedding <=> query_embedding
LIMIT
match_count;
END;
$$;
https://cdn.discordapp.com/attachments/1107262993835774022/1107262994192277584/image.png▾
https://cdn.discordapp.com/attachments/1107262993835774022/1107262994532007937/image.png▾
https://cdn.discordapp.com/attachments/1107262993835774022/1107262994863378532/image.png▾
KinTex
05/14/2023, 12:07 PMnicollegah
05/14/2023, 1:19 PMvalentin-valchev
05/14/2023, 2:40 PMjarnold
05/14/2023, 2:48 PMAuthApiError: Database error finding user
Unlike others, I don't have a public.users
table
It seems like this has been reported multiple times here (discord) over the past year and on github https://github.com/supabase/supabase/issues/1479Canman
05/14/2023, 3:06 PMMared
05/14/2023, 3:12 PMrostero
05/14/2023, 3:49 PMpuffybatman
05/14/2023, 4:02 PMABD
05/14/2023, 4:04 PMLogaritma26
05/14/2023, 4:17 PMmohammadrahi
05/14/2023, 4:40 PMavalanche
05/14/2023, 5:11 PMsql
alter system set maintenance_work_mem = '100000';
but I get this error: 'permission denied to set parameter "maintenance_work_mem"'
The reason I'm trying to do this is because I need to index chat gpt embeddings which require more than 64MB of maintenance_work_mem.
sql
CREATE INDEX ON public.context USING ivfflat (embedding vector_cosine_ops) WITH (lists = 113);
Failed to run sql query: memory required is 65 MB, maintenance_work_mem is 64 MB
Athens Horseparty
05/14/2023, 6:34 PMsql
create or replace function get_user_data(uid_input uuid)
returns setof auth.users as $$
begin
return query select users.id, email, name
from auth.users left join public.profiles
on profiles.user_id = users.id
where users.id = uid_input;
end;
$$ language plpgsql;
When I run the following query
sql
select * from public.get_user_data('6befbf51-8b93-42af-99c3-fd8732fa4c2c')
I get the following error: Failed to run sql query: structure of query does not match function result type
I feel like using a setof users is incorrect since the query it returns is a table with values from profiles as well, but I can't seem to find a good example of what I want to do by searching online. Thanks for your help!Holland
05/14/2023, 6:39 PMnext-dev.js:20 Error: Abort fetching component for route: "/home"
at handleCancelled (router.js:346:27)
at _callee$ (router.js:1249:17)
at tryCatch (runtime.js:45:16)
at Generator.invoke [as _invoke] (runtime.js:274:1)
at prototype.<computed> [as next] (runtime.js:97:1)
at asyncGeneratorStep (_async_to_generator.js:23:1)
at _next (_async_to_generator.js:12:1)
I am using this function:
const loginGoogleHandler = async () => {
console.log('loggin in with google')
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'google',
options: {
redirectTo: `${new URL(location.href).origin}/logging-in?redirect=/home`,
},
})
console.log('results of logging in: ', data, error)
}
I have a logging in component with the following fn:
useEffect(() => {
// check if user has been set in session store then redirect
const url = new URL(window.location.href)
const redirectTo = url.searchParams.get('redirect')
;(async () => {
await waitload(1)
router.push(redirectTo ?? '/posts')
})()
}, [])
It redirects twice to the /logging-in route which is weird and shouldnt do that, and then the printed session is null
In my home route the session is null meaning the google sign in failed, any ideas why.
export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
// Create authenticated Supabase Client
const supabase = createServerSupabaseClient(ctx);
// Check if we have a session
const {
data: { session }
} = await supabase.auth.getSession();
console.log('session: ', session);
if (!session)
return {
redirect: {
destination: '/auth/signin',
permanent: false
}
};
return {
props: {
initialSession: session,
user: session.user
}
};
};
Im really confused cause this works in another project.