Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exists inside select when select items are on separate lines #602

Closed
roveo opened this issue Jun 13, 2024 · 1 comment
Closed

exists inside select when select items are on separate lines #602

roveo opened this issue Jun 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@roveo
Copy link

roveo commented Jun 13, 2024

Describe the bug

When exists clause is used as a column inside select clause, it's put on the same line as the previous column, even when formatter decided to put each column on a separate line.

My thinking is that conceptually exists is a function, the only thing that's special about it is that it has a query as its argument.

To Reproduce

Here's an example (already formatted):

select
    foo as bar, exists (select 1 from baz where qux = quux) as foo1,
    case when something then this else also end as more
from bar1

Expected behavior

select
    foo as bar,
    exists (select 1 from baz where qux = quux) as foo1,
    case when something then this else also end as more
from bar1

Additional context

sqlfmt, version 0.21.3

What is the output of pip list (or pipx list if you installed using pipx)?

Package               Version      Editable project location
--------------------- ------------ -----------------------------------------
antlr4-tools          0.2
appdirs               1.4.4
attrs                 23.1.0
audioread             3.0.1
black                 23.11.0
cattrs                23.2.3
certifi               2023.7.22
cffi                  1.16.0
chardet               5.2.0
charset-normalizer    3.3.0
click                 8.1.7
colorama              0.4.6
contourpy             1.1.1
cycler                0.12.1
decorator             5.1.1
diff_cover            8.0.1
diskcache             5.6.3
docstring-to-markdown 0.13
duckdb                0.9.2
et-xmlfile            1.1.0
fingerprinting        1.0          /Users/roveo/proj/project2/fingerprinting
fonttools             4.43.1
greenlet              3.0.1
gTTS                  2.3.2
idna                  3.4
iniconfig             2.0.0
install-jdk           1.1.0
isort                 5.12.0
jedi                  0.19.1
jedi-language-server  0.41.2
Jinja2                3.1.2
joblib                1.3.2
kiwisolver            1.4.5
lazy_loader           0.3
librosa               0.10.1
llvmlite              0.41.1
lsprotocol            2023.0.0
MarkupSafe            2.1.3
matplotlib            3.8.0
msgpack               1.0.7
mypy-extensions       1.0.0
neovim                0.3.1
numba                 0.58.1
numpy                 1.26.0
openpyxl              3.1.2
packaging             23.2
pandas                2.1.1
parso                 0.8.3
pathspec              0.11.2
Pillow                10.1.0
pip                   24.0
platformdirs          3.11.0
pluggy                1.3.0
pooch                 1.7.0
PyBindGen             0.22.1
pycparser             2.21
pydub                 0.25.1
pygls                 1.2.1
Pygments              2.17.2
pynvim                0.5.0
pyparsing             3.1.1
pytest                7.4.3
python-dateutil       2.8.2
python-lsp-jsonrpc    1.1.2
python-lsp-ruff       2.0.0
python-lsp-server     1.9.0
pytz                  2023.3.post1
PyYAML                6.0.1
regex                 2023.10.3
requests              2.31.0
ruff                  0.1.8
ruff-lsp              0.0.47
scikit-learn          1.3.1
scipy                 1.11.3
setuptools            70.0.0
shandy-sqlfmt         0.21.3
six                   1.16.0
soundfile             0.12.1
soxr                  0.3.7
sqlfluff              2.3.5
tblib                 3.0.0
threadpoolctl         3.2.0
tqdm                  4.66.1
typer                 0.9.0
typing_extensions     4.8.0
tzdata                2023.3
ujson                 5.9.0
urllib3               2.0.6
wheel                 0.43.0
@roveo roveo changed the title Treat exists (...) as a function call exists inside select when select items are on separate lines Jun 13, 2024
@tconbeer tconbeer added the bug Something isn't working label Jul 23, 2024
@tconbeer
Copy link
Owner

just shipped a patch in 0.22.0 -- thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants