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

Postgresql case sensitivity #366

Open
Roemer opened this issue Feb 6, 2019 · 9 comments
Open

Postgresql case sensitivity #366

Roemer opened this issue Feb 6, 2019 · 9 comments

Comments

@Roemer
Copy link

Roemer commented Feb 6, 2019

I noticed that all identifiers (like database name) are converted to lower case. Whereas Postgresql actually supports case sensitivity by default. The rule is, that if an identifier is inside quotes, it is case sensitive, if not, it is not case sensitive. Maybe that's something that should be considered in Roundhouse?

@bladeoflight16
Copy link

bladeoflight16 commented Feb 8, 2019

The naming standard for identifiers in PostgreSQL is all lowercase separated by underscores. Sometimes known as snake-case (because Python popularized it).

Especially in the name of the database itself, there's no benefit to implementing case sensitivity. All it's going to do is cause errors and confusion when people try to connect. This would be especially troublesome in PostgreSQL where the database name must be specified as part of the connection string. "I spelled the name exactly right. Why isn't it connecting? What does it mean the database doesn't exist?"

As for case sensitivity for table and column names and the like, unquoted names are case insensitive by default, as you mention. You should be able to quote them in your script manually if you really need a specific case. E.g., you're trying to match your identifier names in your code.

This is just an opinion, but I'd honestly just advocate for avoiding case sensitivity if at all possible. It's a real pain when you're actually writing SQL in a client like pgAdmin. It's much more convenient to break the programming language's naming standards and match PostgreSQL's than the other way around.

@erikbra
Copy link
Member

erikbra commented Feb 12, 2019

Just so tat I understand you correctly, @bladeoflight16, you think the current behaviour is "more correct" or more convenient in practice?

@bladeoflight16
Copy link

bladeoflight16 commented Mar 4, 2019

@erikbra Both. The database name itself should never be case sensitive. There is no gain to doing so. Other names (tables, views, columns, etc.) created in scripts should be quoted in the script by the author if they want case sensitivity on them; anything in the script currently conforms to default PostgreSQL behavior, as far as I'm aware.

@erikbra
Copy link
Member

erikbra commented Oct 13, 2019

@Roemer do you have any additional comments on this issue? If not, I'm leaning on closing it, given @bladeoflight16's comments

@mnichols-dl
Copy link

Seems like an odd hill to die on for a tool named "RoundhousE"...

I'm having to rename some databases in RDS that were created with PascalCasing. I can't connect to them with RoundhousE in the specific use case of dropping the database. It just seems unnecessary to enforce best practice in a way that breaks the tool for some instead of just expecting that people use the correct name in the connection string. If they don't know the casing or can't figure that out quick enough, that's on them, right?

@erikbra
Copy link
Member

erikbra commented Apr 13, 2020

Just a question of clarification, @mnichols-dl , Are you not able to connect to the databases that have PascalCase, or do you have several databases that differ only in casing? If the first is the issue, then we have a more serious problem. Of course you should be able to connect to your databases no matter the casing.

I'm not fluent at all in PostgreSQL. Do you have any thoughts on how we could change RoundhousE so that it accepts any case of the DB? Do we use quotes where we shouldn't anywhere, or are there other issues?

@Roemer
Copy link
Author

Roemer commented Apr 13, 2020

I was unable to do anything with a database that was not fully lowercase, I had to rename them in order for RoundhousE to work.

@bladeoflight16
Copy link

@Roemer I suggest changing the title and description of the ticket to reflect that. That's a bug. Your request appeared to be asking for case sensitivity to be added to RoundhousE.

@erikbra
Copy link
Member

erikbra commented Nov 13, 2021

@Roemer, could you please check if https://github.com/erikbra/grate solves this problem for you? I think it should.

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

No branches or pull requests

4 participants