Skip to content

termsql removes whitespace between tokens with subqueries #17

@comex

Description

@comex

In the following example, termsql removes whitespace between the tokens 1 and from, leading to invalid syntax:

$ echo 1 | uv run --with sqlparse ./termsql -Q 'select (select 1 from tbl)'
select(select 1from tbl) from tbl ;

sqlparse formats it as:

'select\n  (select 1\n   from tbl)'

But when termsql is joining lines, the line starting with ' from' hits this condition:

            elif line.lower().startswith("select") or line.startswith(' '):
                s += line.lstrip()

so all the spaces are removed, and so is the newline.

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