mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-19 13:03:14 +12:00
improvement: remove LEAKPROOF from function to prevent migration issues
chore: add some tests to show calculation w/ fragment
This commit is contained in:
parent
ec3273f163
commit
e2b648a9e4
3 changed files with 9 additions and 1 deletions
|
@ -230,7 +230,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
|
||||
IMMUTABLE PARALLEL SAFE STRICT LEAKPROOF;
|
||||
IMMUTABLE PARALLEL SAFE STRICT;
|
||||
\"\"\")
|
||||
"""
|
||||
end
|
||||
|
|
|
@ -312,6 +312,10 @@ defmodule AshPostgres.CalculationTest do
|
|||
refute Ash.calculate!(Post, :author_has_post_with_follower_named_fred, refs: %{id: post.id})
|
||||
end
|
||||
|
||||
test "calculation works with simple fragments" do
|
||||
Post.upper_title!("example")
|
||||
end
|
||||
|
||||
test "calculations that refer to aggregates can be authorized" do
|
||||
post =
|
||||
Post
|
||||
|
|
|
@ -409,6 +409,8 @@ defmodule AshPostgres.Test.Post do
|
|||
define(:increment_score, args: [{:optional, :amount}])
|
||||
define(:destroy)
|
||||
define(:update_constrained_int, args: [:amount])
|
||||
|
||||
define_calculation(:upper_title, args: [:title])
|
||||
end
|
||||
|
||||
relationships do
|
||||
|
@ -542,6 +544,8 @@ defmodule AshPostgres.Test.Post do
|
|||
calculations do
|
||||
calculate(:upper_thing, :string, expr(fragment("UPPER(?)", uniq_on_upper)))
|
||||
|
||||
calculate(:upper_title, :string, expr(fragment("UPPER(?)", title)))
|
||||
|
||||
calculate(
|
||||
:author_has_post_with_follower_named_fred,
|
||||
:boolean,
|
||||
|
|
Loading…
Reference in a new issue