Skip to content

feat: setup aliasing in dialects - #15318

Closed
frostzt wants to merge 3 commits into
sequelize:mainfrom
frostzt:fix/shorten-length-for-postgres-alisas
Closed

frostzt wants to merge 3 commits into
sequelize:mainfrom
frostzt:fix/shorten-length-for-postgres-alisas

Conversation

@frostzt

@frostzt frostzt commented Nov 21, 2022 •

Copy link
Copy Markdown
Member

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description Of Change

First reported in #14118
Since DBMSs are only able to support identifiers up until certain lengths therefore any identifier that crosses that limit should either be aliased or an error should be thrown.

@frostzt
frostzt marked this pull request as draft November 21, 2022 17:40
@frostzt

frostzt commented Nov 21, 2022

Copy link
Copy Markdown
Member Author

Hey @ephys really sorry for the ping. But I tried looking into this issue, took some time however I am having a little trouble. Can you guide me a little.

Questions:

  • The issues are with both alias lengths and the ones present in the select statement can I simply create a function that creates a small alias for it? How will that be reused everywhere?

@ephys

ephys commented Nov 22, 2022

Copy link
Copy Markdown
Member

There already is one but I don't know how it works: https://github.com/sequelize/sequelize/blob/main/src/dialects/abstract/query-generator.js#L1705-L1730

any identifier that crosses that limit should either be aliased or an error should be thrown.

By default it should throw an error explaining that the alias generated by sequelize would be too long but that the user can use the minifyAliases option to enable alias minification.

Note that right now minifyAliases is a global option. I'd be awesome and cause a lot less headaches to be able to turn it for a single SELECT too so the user only enables it for the queries that need it.

@WikiRik

WikiRik commented Nov 23, 2022

Copy link
Copy Markdown
Member

This would also be a nice PR to check out if the minifyAliases option in the CI still makes sense. I think that we already have tests that create a custom instance where minifyAliases is enabled, even if it's not set by the CI.

@ephys

ephys commented Nov 23, 2022

Copy link
Copy Markdown
Member

I'd also like to remove it:

  • it's only relevant in SELECT queries (I think?), no need to run the whole test suite just for that
  • it's only running against postgres but other dialects support the option too

But our current SELECT test suites aren't fully covering it yet. We'll need to overhaul it before we can remove it from the CI. Maybe as part of #15260 ?

@frostzt frostzt closed this by deleting the head repository Aug 22, 2026
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.

3 participants