db/schema/0012_newtype.sql

17 lines
600 B
MySQL
Raw Normal View History

2023-06-10 17:04:03 +00:00
create function create_newtype_text(qualified_name text)
returns void
language plpgsql
as $$
begin
execute concat('create type ', qualified_name, ' as (str text);');
execute concat( 'create function '
, qualified_name || '_to_string(val ' || qualified_name || ')'
, E' returns text language sql as \'select (val.str);\';'
);
execute concat( 'create function '
, qualified_name || '_of_string(val text)'
, ' returns ' || qualified_name || E' language sql as \'select row(val);\';'
);
end;
$$;