robotdood
01/04/2022, 8:41 PMslug
column that auto slugifies the value of another column on INSERT
and/or UPDATE
?
I attempted to add this function, but am unable to set the return type to `trigger`: https://www.kdobson.net/2019/ultimate-postgresql-slug-function/
Another option I saw in the comments of the gist (linked at bottom of that blog post) was to have a generated column a la:
CREATE TABLE person (
name text not null,
slug text generated always as (slugify(name)) stored
);
Not sure how to create a generated column within Supabase, though. Any ideas?Scott P
01/04/2022, 8:45 PMrobotdood
01/04/2022, 8:47 PMjensen
01/04/2022, 8:51 PMjensen
01/04/2022, 8:52 PMjensen
01/04/2022, 8:52 PMjensen
01/04/2022, 9:02 PMrobotdood
01/04/2022, 9:52 PMslugify
function with a return type of text
(which I'm assuming I need when using with the associated function that returns a trigger
). I get "Failed to create function: return type mismatch in function declared to return text"
.
I'm not sure how to define an extension
in the Supabase UI as @User has done with unaccent
in their implementation, so I'm unable to try their seeming much simpler trigger function.
I've also just tried testing a function that returns a trigger
that just copies the new.title
value into the new.slug
column and I'm getting a "stack depth limit exceeded"
error, which I think is due to setting my trigger to run on UPDATE
as well as INSERT
?
Going to grab some food, but I'll keep trying 😛jensen
01/04/2022, 9:53 PMjensen
01/04/2022, 9:54 PMunaccent
.jensen
01/04/2022, 9:55 PMCREATE EXTENSION
robotdood
01/04/2022, 9:59 PMjensen
01/04/2022, 11:45 PMunaccent
would be create extension unaccent with schema extensions;
jensen
01/04/2022, 11:51 PMrobotdood
01/05/2022, 12:30 AMsupabase.rpc()
API at least) but when I ask a trigger function to run it I get "regular expression failed: regular expression is too complex"
🤔
And that's with the trigger set to INSERT
only, for now..robotdood
01/05/2022, 2:00 AMslug
column(s) and re-created them with the code below that sets the default value of the slug
column to slugify(title)
.
I initially tried doing this in Supabase's UI but was getting "cannot use column reference in DEFAULT expression"
errors, which doesn't seem to be an issue when creating the columns with the code below:
ALTER TABLE name_of_table DROP IF EXISTS slug;
ALTER TABLE name_of_table
ADD slug text generated always as (slugify(title)) stored;
robotdood
01/05/2022, 2:09 AM"column "slug" can only be updated to DEFAULT"
error when updating title
cells (at least via the UI)
AND, it seems to fail when attempting to add a new user. I set up a profiles
table with one of Supabase's templates and it gets populated when a new user signs up. I am attempting to slugify the username and I'm getting a 500
Internal Server Error
in the browser (not sure how else to test this one)