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

sqlDataTypeCase and sqlFunctionCase options? #13

Open
karlhorky opened this issue Dec 3, 2023 · 3 comments
Open

sqlDataTypeCase and sqlFunctionCase options? #13

karlhorky opened this issue Dec 3, 2023 · 3 comments

Comments

@karlhorky
Copy link

Similar to the dataTypeCase and functionCase in sql-formatter:

It seems like this would be much simpler to implement here, because according to SQL Explorer the node types already exist:

Screenshot 2023-12-03 at 12 37 22

Screenshot 2023-12-03 at 12 39 57

@nene
Copy link
Owner

nene commented Dec 3, 2023

Yeah. It's definitely much simpler to achieve in here.

@nene
Copy link
Owner

nene commented Dec 3, 2023

Also worth considering are the capitalization rules in SQLFluff. It implements 5 categories:

  • identifiers
  • keywords
  • types
  • literals (like NULL)
  • functions

It might be good to align our implementation with that. Though on the other hand I'd like to avoid configuration options and keep this plugin opinionated... but capitalization is an area where I've already decided that it's better for it to be configurable. This still leaves the question of picking the best defaults.

  • keywords and literals should default to uppercase (these literals are really just a subset of keywords)
  • identifier and function names to lower case (again, function names are a type of identifiers, though some dialects treat them as keywords. There are also some strange things like CURRENT_DATE which are functions, but with a special parenthesis-less syntax).
  • types... I'm not so sure about. Most dialects have a limited built-in set of types, but e.g. Postgres allows defining custom ones and SQLite pretty much ignores all type information. Most SQL I've come across to has types in uppercase though, which might be a better cross-dialect default.

@karlhorky
Copy link
Author

karlhorky commented Dec 3, 2023

Sounds reasonable to me 👍

Data types defaulting to uppercase is probably a good default too - the PostgreSQL docs seem like an outlier when it comes to their usage of lowercase data types

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

No branches or pull requests

2 participants