alejandrogb92
04/14/2022, 9:28 AMMuezz
04/15/2022, 1:56 PMsql
if new."category" is "rand_category"
then
//Do somthing
else
//Do somthing else
end if;
Is this the correct way of checking the value of a particular column in the newly added row?garyaustin
04/15/2022, 2:15 PMoren
04/16/2022, 9:13 AMgaryaustin
04/16/2022, 1:49 PMselect * from information_schema.key_column_usage
where constraint_catalog=current_catalog
and position_in_unique_constraint notnull;
Muezz
04/16/2022, 9:24 PMrpc
which takes a json doc as an argument and adds not the doc itself but the data from it into a table. For instance, the keys
will be the column names and the values
will be the data that need to be added.Muezz
04/16/2022, 9:39 PMsql
create or replace function insert_json(_js json)
returns void
language plpgsql
as $$
begin
INSERT INTO db_transactions
SELECT * FROM json_populate_record (NULL::db_transactions, _js);
end;
$$;
insert_json({'t_date':now(),'category':'random_category','amount':120,'deb_acc':'acc_1','cred_acc':'acc_2'});
tourdownunder
04/16/2022, 11:59 PMMuezz
04/17/2022, 7:38 PMjoshcowan25
04/18/2022, 5:00 AMoren
04/18/2022, 12:55 PMJonWasTaken
04/19/2022, 3:59 AMALTER TABLE props ADD COLUMN textSearch tsvector GENERATED ALWAYS AS (
setweight(to_tsvector('english', coalesce(name, '')), 'A') ||
setweight(to_tsvector('english', coalesce(terms,'')), 'B')
) STORED;
CREATE INDEX props_textsearch_idx ON props USING GIN (textSearch);
I get the following error:
db error: ERROR: malformed array literal: ""
DETAIL: Array value must start with "{" or dimension information.
0: sql_migration_connector::validate_migrations
at migration-engine\connectors\sql-migration-connector\src\lib.rs:271
1: migration_core::state::DevDiagnostic
at migration-engine\core\src\state.rs:248
The syntax should be correct as I've seen it in multiple sources, so I'm wondering if it's a supabase specific problem maybe?JonWasTaken
04/19/2022, 4:15 AMgaryaustin
04/19/2022, 4:22 AMJonWasTaken
04/19/2022, 4:25 AMALTER TABLE props ADD COLUMN "textSearch" tsvector GENERATED ALWAYS AS (
setweight(to_tsvector('english', coalesce(name, '')), 'A') ||
setweight(to_tsvector('english', coalesce(terms,'')), 'B')
) STORED;
-- CreateIndex
CREATE INDEX props_textSearch_idx ON props USING GIN ("textSearch");
I wonder if the issue is that the type for terms
is actually string[]
not just string
like name isgaryaustin
04/19/2022, 4:27 AMJonWasTaken
04/19/2022, 4:31 AMALTER TABLE props ADD COLUMN search tsvector GENERATED ALWAYS AS (
setweight(to_tsvector('english', coalesce(name, '')), 'A') ||
setweight(to_tsvector('english', coalesce(terms,'')), 'B')
) STORED;
-- CreateIndex
CREATE INDEX searchidx ON props USING GIN (search);
garyaustin
04/19/2022, 4:43 AMJonWasTaken
04/19/2022, 5:00 AMjaitaiwan
04/19/2022, 9:25 AMScott P
04/19/2022, 8:07 PM(d,f,g)=> 🥁
04/20/2022, 8:41 PMprimary key(item_id, user_id)
how do i write a check constraint that limits the amount of rows a user can make on an item? i dont know any way to use aggregates like max/count in indexes or check constraints...Muezz
04/20/2022, 8:53 PMgaryaustin
04/21/2022, 1:29 AMElectricDragon
04/21/2022, 11:15 AMScott P
04/21/2022, 4:52 PM(d,f,g)=> 🥁
04/21/2022, 8:23 PMsql
create table comments (
comment_id int primary key generated always as identity,
user_id uuid references auth.users default auth.uid(),
blog_slug text not null,
parent_id int references comments,
body text not null check(length(body) between 1 and 2000),
created_at timestamptz not null default now()
);
create index on comments (blog_slug);
create index on comments (parent_id);
alter table comments enable row level security;
create policy select_all on comments for select using (true);
create policy insert_own on comments for insert with check (user_id = auth.uid());
create policy update_own on comments for update using (user_id = auth.uid());
create policy delete_own on comments for delete using (user_id = auth.uid());
this this is all typical stuff, but will these work as i expect? sql
grant select on comments to anon;
grant
insert (blog_slug, body, post_id, parent_id),
update (body),
delete
on comments to authenticated;
Edgar
04/23/2022, 10:26 PMDanMossa
04/24/2022, 4:32 PMMuezz
04/26/2022, 8:12 PM