Skip to content

Commit d82cf72

Browse files
committed
escape " within the SQL
1 parent cb88a85 commit d82cf72

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

lib/realtime/tenants/repo/migrations/20240423161054_use_fully_qualified_names.ex

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ AS $function$
1616
Builds a sql string that, if executed, creates a prepared statement to
1717
tests retrive a row from *entity* by its primary key columns.
1818
Example
19-
select realtime.build_prepared_statement_sql('public.notes', '{"id"}'::text[], '{"bigint"}'::text[])
19+
select realtime.build_prepared_statement_sql('public.notes', '{\"id\"}'::text[], '{\"bigint\"}'::text[])
2020
*/
2121
select
2222
'prepare ' || prepared_statement_name || ' as
@@ -40,10 +40,10 @@ $function$;
4040
-- cast function
4141
4242
CREATE OR REPLACE FUNCTION realtime.\"cast\"(val text, type_ regtype)
43-
RETURNS jsonb
44-
LANGUAGE plpgsql
45-
SET search_path = ''
46-
IMMUTABLE
43+
RETURNS jsonb
44+
LANGUAGE plpgsql
45+
SET search_path = ''
46+
IMMUTABLE
4747
AS $function$
4848
declare
4949
res jsonb;
@@ -56,21 +56,21 @@ $function$;
5656
-- channel_name function
5757
5858
CREATE OR REPLACE FUNCTION realtime.channel_name()
59-
RETURNS text
60-
SET search_path = ''
61-
LANGUAGE sql
62-
STABLE
59+
RETURNS text
60+
SET search_path = ''
61+
LANGUAGE sql
62+
STABLE
6363
AS $function$
6464
select nullif(pg_catalog.current_setting('realtime.channel_name', true), '')::text;
6565
$function$;
6666
6767
-- check_equality_op function
6868
6969
CREATE OR REPLACE FUNCTION realtime.check_equality_op(op realtime.equality_op, type_ regtype, val_1 text, val_2 text)
70-
RETURNS boolean
71-
LANGUAGE plpgsql
70+
RETURNS boolean
71+
LANGUAGE plpgsql
7272
SET search_path = ''
73-
IMMUTABLE
73+
IMMUTABLE
7474
AS $function$
7575
/*
7676
Casts *val_1* and *val_2* as type *type_* and check the *op* condition for truthiness
@@ -141,10 +141,10 @@ $function$;
141141
142142
-- quote_wal2json function
143143
CREATE OR REPLACE FUNCTION realtime.list_changes(publication name, slot_name name, max_changes integer, max_record_bytes integer)
144-
RETURNS SETOF realtime.wal_rls
145-
LANGUAGE sql
146-
SET search_path = ''
147-
SET log_min_messages TO 'fatal'
144+
RETURNS SETOF realtime.wal_rls
145+
LANGUAGE sql
146+
SET search_path = ''
147+
SET log_min_messages TO 'fatal'
148148
AS $function$
149149
with pub as (
150150
select
@@ -216,21 +216,21 @@ AS $function$
216216
select pg_catalog.string_agg('' || ch,'')
217217
from pg_catalog.unnest(pg_catalog.string_to_array(nsp.nspname::text, null)) with ordinality x(ch, idx)
218218
where
219-
not (x.idx = 1 and x.ch = '"')
219+
not (x.idx = 1 and x.ch = '\"')
220220
and not (
221221
x.idx = pg_catalog.array_length(pg_catalog.string_to_array(nsp.nspname::text, null), 1)
222-
and x.ch = '"'
222+
and x.ch = '\"'
223223
)
224224
)
225225
|| '.'
226226
|| (
227227
select string_agg('' || ch,'')
228228
from pg_catalog.unnest(pg_catalog.string_to_array(pc.relname::text, null)) with ordinality x(ch, idx)
229229
where
230-
not (x.idx = 1 and x.ch = '"')
230+
not (x.idx = 1 and x.ch = '\"')
231231
and not (
232232
x.idx = pg_catalog.array_length(pg_catalog.string_to_array(nsp.nspname::text, null), 1)
233-
and x.ch = '"'
233+
and x.ch = '\"'
234234
)
235235
)
236236
from

0 commit comments

Comments
 (0)