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

Make \copy case-insensitive #152

Merged
merged 1 commit into from
Nov 26, 2024
Merged

Conversation

jdpopkin
Copy link
Contributor

@jdpopkin jdpopkin commented Nov 22, 2024

\COPY behaves exactly like \copy in psql - see psql's slash-command-parsing
function
and note the use of pg_strcasecmp. So some users expect to be able to use \COPY in pgcli. This commit makes that happen.

Description

psql treats \copy, \COPY, \cOpY, etc. the same way. (See postgres source.) I hadn't known that until earlier today - a coworker who was trying out pgcli for the first time in a while was disappointed that pgcli still doesn't support \COPY. This PR is meant to fix that.

Checklist

  • I've added this contribution to the changelog.rst.
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install), and ran black on my code.
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

Caveat 1: I'm not sure I used black correctly. I managed to kick it off imperatively at some point against the whole repo, and it only seemed to make one change (deleting a blank line in a file I hadn't edited). So hopefully it's okay with whatever I've done here?

Caveat 2: a couple of integration tests are red for me locally. Specifically, ones about listing users seem surprised/upset by the amount of stuff that's owned by my local macOS user and not postgres. I'm pretty sure this is just because I messed up setting up my local database, and not because of anything introduced by my code change? But I wanted to call attention to it in case I'm misunderstanding.

pgspecial/iocommands.py Outdated Show resolved Hide resolved
@j-bennet
Copy link
Contributor

@jdpopkin thanks for the PR! It does not look like all of your changes were checked in, can you make sure?

`\COPY` behaves exactly like `\copy` in `psql` - see [psql's
slash-command-parsing
function](https://github.com/postgres/postgres/blob/ea15816928c1bbcab749205a263d82daea28a3e0/src/bin/psql/command.c#L330)
and note the use of `pg_strcasecmp`. So some users expect to be able to
use `\COPY` in pgcli. This commit makes that happen.
@j-bennet
Copy link
Contributor

Thank you @jdpopkin , merging!

@j-bennet j-bennet merged commit a011bb6 into dbcli:main Nov 26, 2024
6 checks passed
@j-bennet
Copy link
Contributor

Your change is released in https://pypi.org/project/pgspecial/2.1.3/.

Thank you!

🌟

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants