Skip to content

A -- comment before a subquery comments out the subquery #63

Description

@gmr

Problem

A -- comment just before a parenthesized subquery loses the newline that ends it. The subquery then goes onto the comment line, and PostgreSQL reads it as part of the comment. The output does not parse.

This occurs in every style except pg_dump (fixed for pg_dump in #59). It also occurs on main.

Reproduce

SELECT a FROM t WHERE x IN -- note
 (SELECT 1);

river output:

SELECT a
  FROM t
 WHERE x IN -- note (SELECT 1)
;

Formatting the output again fails: Syntax error at line 3, column 10: "IN". mozilla, aweber, dbt, gitlab, kickstarter and mattmc3 give the same result.

Expected

The newline after the comment stays, so (SELECT 1) remains SQL.

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions