Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: add search path to postgres functions #449

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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