Skip to content

Commit

Permalink
bug: add search path to postgres functions (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexslade authored Dec 25, 2024
1 parent e47cf93 commit 7e0c205
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/migration_generator/ash_functions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ defmodule AshPostgres.MigrationGenerator.AshFunctions do
CREATE OR REPLACE FUNCTION ash_elixir_or(left BOOLEAN, in right ANYCOMPATIBLE, out f1 ANYCOMPATIBLE)
AS $$ SELECT COALESCE(NULLIF($1, FALSE), $2) $$
LANGUAGE SQL
SET search_path = ''
IMMUTABLE;
\"\"\")
execute(\"\"\"
CREATE OR REPLACE FUNCTION ash_elixir_or(left ANYCOMPATIBLE, in right ANYCOMPATIBLE, out f1 ANYCOMPATIBLE)
AS $$ SELECT COALESCE($1, $2) $$
LANGUAGE SQL
SET search_path = ''
IMMUTABLE;
\"\"\")
Expand All @@ -27,6 +29,7 @@ defmodule AshPostgres.MigrationGenerator.AshFunctions do
ELSE $1
END $$
LANGUAGE SQL
SET search_path = ''
IMMUTABLE;
\"\"\")
Expand All @@ -37,6 +40,7 @@ defmodule AshPostgres.MigrationGenerator.AshFunctions do
ELSE $1
END $$
LANGUAGE SQL
SET search_path = ''
IMMUTABLE;
\"\"\")
Expand All @@ -62,6 +66,7 @@ defmodule AshPostgres.MigrationGenerator.AshFunctions do
END IF;
END; $$
LANGUAGE plpgsql
SET search_path = ''
IMMUTABLE;
\"\"\")
Expand Down Expand Up @@ -115,6 +120,7 @@ defmodule AshPostgres.MigrationGenerator.AshFunctions do
END IF;
END; $$
LANGUAGE plpgsql
SET search_path = ''
IMMUTABLE;
\"\"\")
"""
Expand Down Expand Up @@ -177,7 +183,8 @@ defmodule AshPostgres.MigrationGenerator.AshFunctions do
RAISE EXCEPTION '#{prefix}%', json_data::text;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
$$ LANGUAGE plpgsql
SET search_path = '';
\"\"\")
execute(\"\"\"
Expand All @@ -189,7 +196,8 @@ defmodule AshPostgres.MigrationGenerator.AshFunctions do
RAISE EXCEPTION '#{prefix}%', json_data::text;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
$$ LANGUAGE plpgsql
SET search_path = '';
\"\"\")
"""
end
Expand Down Expand Up @@ -220,6 +228,7 @@ defmodule AshPostgres.MigrationGenerator.AshFunctions do
END
$$
LANGUAGE PLPGSQL
SET search_path = ''
VOLATILE;
\"\"\")
Expand All @@ -230,6 +239,7 @@ defmodule AshPostgres.MigrationGenerator.AshFunctions do
SELECT to_timestamp(('x0000' || substr(_uuid::TEXT, 1, 8) || substr(_uuid::TEXT, 10, 4))::BIT(64)::BIGINT::NUMERIC / 1000);
$$
LANGUAGE SQL
SET search_path = ''
IMMUTABLE PARALLEL SAFE STRICT;
\"\"\")
"""
Expand Down

0 comments on commit 7e0c205

Please sign in to comment.