Skip to content

fragment in calculations do not take postgis schema's into consideration #2106

@kernel-io

Description

@kernel-io

I'm attempting to do a ST_Union on a related resource, but that resource is stored in a different schema

calculate :geom, :geometry, expr(fragment("ST_UNION(?)", lgas.geog))

It seems that Ash is not adding the schema (which is defined on the resource) to the query i.e:

* ** (Postgrex.Error) ERROR 42P01 (undefined_table) relation "public.lga" does not exist

    query: SELECT DISTINCT ON (s0."id") s0."id", s0."name", s0."inserted_at", s0."updated_at", s0."area", (ST_UNION(l2."geog"))::geometry FROM "service_areas" AS s0 LEFT OUTER JOIN "public"."lga_service_areas" AS l1 ON s0."id" = l1."service_area_id" LEFT OUTER JOIN "public"."lga" AS l2 ON l2."gid" = l1."gid" WHERE (s0."id"::uuid = $1::uuid::uuid)

I'd expect the generated SQL to have the correct schema reference. For reference the resource that the calculation is defined on is in a different domain and different schema than the LGA resource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions