Muezz
06/06/2022, 3:37 PMjensen
06/06/2022, 3:40 PMMuezz
06/06/2022, 5:37 PMjensen
06/06/2022, 7:05 PMjar
06/07/2022, 4:09 AMif (jsonb_typeof(jsonb_extract_path(child, 'id')) = 'null' or (not child->'id'::uuid)) then
child = jsonb_set(child::jsonb,'{id}',to_jsonb(uuid_generate_v4()));
end if;
chipilov
06/07/2022, 7:46 AMbaptisteArno
06/07/2022, 12:19 PMcol
for example has: [{id: "block 1", steps: [...]}, {id: "block 2", steps: [...]}]
, I'd like to rename all the steps
keys to blocks
on all rows.
Here is what I found: https://stackoverflow.com/questions/50871692/how-to-rename-a-key-in-a-jsonb-list
So, I tried:
sql
update "Typebot" t1
set col =
(select json_agg(el::jsonb - 'steps' || jsonb_build_object('blocks', el->'steps'))
from "Typebot" t2, jsonb_array_elements(t2.col) as el
where t1.id = t2.id)
But it says: function jsonb_array_elements(jsonb[]) does not exist
tourdownunder
06/07/2022, 11:21 PMt2.col
into just jsonb
baptisteArno
06/08/2022, 5:44 AMdbristow
06/09/2022, 6:26 PMchipilov
06/10/2022, 6:35 AMtourdownunder
06/12/2022, 12:05 AMbaptisteArno
06/14/2022, 9:47 AMsql
select w.id, (
SELECT COUNT(*)
FROM "MemberInWorkspace" m
WHERE w.id = m."workspaceId"
) AS count
from "Workspace" w
group by w.id
where count>2
it says: Failed to validate sql query: syntax error at or near "where"
jaitaiwan
06/14/2022, 9:53 AMbaptisteArno
06/14/2022, 10:03 AMwhere
line, it works fine! I just don't understand why I can't add this last linejaitaiwan
06/14/2022, 10:13 AMjaitaiwan
06/14/2022, 10:14 AMbaptisteArno
06/14/2022, 11:58 AMfernandolguevara
06/14/2022, 12:23 PMfernandolguevara
06/14/2022, 12:23 PMfernandolguevara
06/14/2022, 12:24 PMsql
SELECT
customer_id,
SUM (amount)
FROM
payment
GROUP BY
customer_id
HAVING
SUM (amount) > 200;
fernandolguevara
06/14/2022, 12:24 PMLior539
06/16/2022, 1:25 PMPosts
. A post is created by a User
and so has a posts.user_id
column. A User
also belongs to a Company
, so a user has a users.company_id
column
I want to write a policy such that the authed user can SELECT any post created by any user in his company. I have the following SQL statement:
CASE
WHEN (( SELECT u.company_id
FROM users u
WHERE (u.id = posts.user_id)
LIMIT 1) = ( SELECT v.company_id
FROM users v
WHERE (v.id = uid())
LIMIT 1)) THEN true
ELSE false
END
Its not working for me, I suspect because the syntax is wrong (I've never really written statements that return booleans)Lior539
06/16/2022, 1:31 PMLior539
06/16/2022, 1:48 PMmansueli
06/16/2022, 1:50 PMcompany_id
in the posts table as well.Lior539
06/16/2022, 1:52 PMmansueli
06/16/2022, 1:55 PMLior539
06/16/2022, 1:57 PMmansueli
06/16/2022, 2:02 PM