Skip to content

[BUG] Incorrect generated sql when using with #14

Description

@sezaru

I have the following query:

    sql = ~SQL"""
    with subset as (
      select distinct on (e.id) e.id as row_id
      from "pacman.public".entities as e
      join "pacman.public".transactions as t on t.entity_id = e.id
      where e.status = 'done'
        and t.strategy = 'unknown'
        and t.sell_record_id is null
        and t.buy_date < now() - interval '365 days'
    )
    update "pacman.public".entities
    set status = 'stale'
    from subset
    where id = subset.row_id
    """

If I use to_sql to see the generated sql, I get this result:

iex(pacman@node1.backend.core)6> sql |> to_sql
{"with update \"pacman.public\".entities set status = 'stale' from subset where id = subset.row_id", []}

Seems like SQL ignored the full with expression

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions