Jshen
12/17/2021, 8:42 PMScott P
12/17/2021, 8:58 PMint
.
For example, 100 cents would be 1 dollar. That provides you with the most flexibility, and avoids issues with some languages like JS where 1.00
would get truncated to 1
, or 1.10
would become 1.1
(which looks strange in most currencies, compared to 1.10
).Jshen
12/17/2021, 8:59 PMWatt
12/17/2021, 9:28 PMSELECT agent_code,
SUM (advance_amount)
FROM orders
GROUP BY agent_code;
But is seems supabase.js does not have SUM or GROUP BY. Is the only way to accomplish this via stored procedures?Watt
12/17/2021, 10:26 PMcreate or replace function get_top()
returns table (author_id int, upvotes int) as
$$
SELECT author_id,
SUM (upvotes)
FROM karma
GROUP BY author_id;
$$
language sql;
Something like that works. Had to use DROP FUNCTION get_top()
that was the key.kresimirgalic
12/20/2021, 6:54 PMScott P
12/20/2021, 7:20 PMJshen
12/21/2021, 2:53 AMchipilov
12/21/2021, 9:27 AMMihai Andrei
12/21/2021, 7:41 PMMihai Andrei
12/21/2021, 7:41 PMJshen
12/21/2021, 7:43 PMktosiek
12/22/2021, 7:51 AMTremalJack
12/23/2021, 2:40 PMCREATE FUNCTION is_member_of(_user_email text, _channel_id int8) RETURNS bool AS $$
SELECT EXISTS (
SELECT 1
FROM channel_users cu
WHERE cu.channel_id::int8 = _channel_id::int8
AND cu.user_mail::text = _user_email::text
);
$$ LANGUAGE sql SECURITY DEFINER;
then I created a policy for the table channel_users on SELECT using:
is_member_of(auth.email(), channel_id)
then I created another policy always for the same table on UPDATE:
(auth.email() = (user_mail)::text)
the result I expect is:
Im able to update all channel_users rows contain my email
Im able to select all channel_users rows contain an channel_id where Im in
but... into reality... I select, I update, but at moment to set an realtime taks on UPDATE
this.supabase
.from(`channel_users:channel_id=eq.${this.data.channelID}`)
.on('UPDATE', payload => {
console.log(payload)
if (payload.new.user_mail !== this.data.user_loged.user.email) {
this.data.responderIsTyping = payload.new.is_typing
}
})
.subscribe()
He never trigger it (yes replication is enable), if I change the Select policy from is_member_of(auth.email(), channel_id)
to true
then the realtime update subscription receive the trigger.... any suggestion?beru
12/23/2021, 5:07 PM(auth.uid() = id)
). things did not work until the check is removed. when i ran supabase.auth.session()
or supabase.auth.user()
, they both returned null even though i'm logged in, so i suspect the issue is related to this somehow.isaiah
12/25/2021, 1:42 AMselect test_column
from test_table
where test_column = 1234567890123456789;
on supabase.io, and
await supabase.from('test_table').select().match({test_column:1234567890123456789})
in my JS code will both give me back the value 1234567890123456**800**isaiah
12/25/2021, 1:42 AMisaiah
12/25/2021, 1:44 AMchipilov
12/25/2021, 10:14 PMchipilov
12/25/2021, 10:16 PMisaiah
12/26/2021, 1:39 AMchipilov
12/26/2021, 9:23 AMchipilov
12/26/2021, 9:54 AMPrefix
12/26/2021, 8:49 PMINSERT
and UPDATE
events for that table. I go into detail in this github issue: https://github.com/supabase/realtime/issues/213
basically: my table board_cards
has this policy check for all operations: is_member_of_list(uid(), list_id)
.
that is calls a custom postgres function defined as:
sql
SELECT EXISTS (
SELECT 1
FROM team_memberships tm
WHERE tm.user_id = uid
AND tm.team_id = (
SELECT team_id
FROM team_boards tb
WHERE tb.id = (
SELECT board_id
FROM board_lists bl
WHERE bl.id = list_id
)
)
)
This works correctly via REST calls, however it seems to break realtime.
If I turn OFF RLS for the table, I am correctly receiving INSERT
and UPDATE
events.TremalJack
12/26/2021, 11:44 PMTremalJack
12/26/2021, 11:47 PMtourdownunder
12/26/2021, 11:51 PMSECURITY DEFINER;
from your function definition. As I understand it that may change the RLS behaviour.TremalJack
12/26/2021, 11:52 PMTremalJack
12/26/2021, 11:53 PMTremalJack
12/26/2021, 11:54 PM