-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Draft RFC] Using Op.* as functions on top of keys #13
Comments
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
still ready to work on this if interested :) |
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
Hi @ephys |
Still intending on working on this but replacing the symbols with functions+Symbol.toPrimitive could be a breaking change for some users. Is the main branch considered v7 or should I wait? |
We do not have a v7 branch yet, but that might be good to have. @sdepold do you agree? EDIT: Would be good if the v7 branch only accepts PRs in TypeScript so we don't have to convert those later |
I'm not sure if we can have constraints on the language automatically somehow or if that is more a part of the review process |
We can even setup automated releases of a v7 alpha version to npm if you think that makes sense |
Thanks! I think it's possible to add a check that ensures touched files do not end in .js, but it's easier to add a note in the PR guidelines I think. |
Are the PR guidelines taken from the target or the source branch? :D |
I think from the target but only one way to find out :) |
I guess since we will remove JS code, having it in the documentation might be more useful. What do you think ? sequelize/sequelize#13747 |
I'd say a simple note in CONTRIBUTING.md should be enough |
After working on a prototype, here are my findings: TypeScript has very little support for it breaks the typing of The following TypeScript issues are relevant:
I see three options going forward, none of which are particularly amazing:
|
Due to TypeScript not supporting import { notEqual } from 'sequelize';
User.findAll({
where: { id: notEqual(5) }
}); That's a lot of extra exports with very generic names though :/ |
In general I like the proposal but would maybe not expose it via sequelize but maybe add a layer or nesting? Import { Operators} from sequelize Const { notEqual}=Operators ? |
I agree, but If we expose something like This issue is frustrating. I have a solution that is almost working but it causes typescript to stop reporting errors with the current way of using operators: |
I'm transfering RFCs to the main repo to gather feedback from users of the library, but I won't migrate this one because I'm not happy with it yet |
Feel free to make a new issue that supersedes this one to have a cleaner discussion |
Feature Description
Is your feature request related to a problem? Please describe.
I've personally never liked the ergonomics of having to use sequelize operators as keys for an object.
The following code
feels easier to read when written like this:
Describe the solution you'd like
We could make it possible to use Op.* as both object keys and functions using toPrimitive. That would make both snippets of code above valid.
Proof of concept:
Why should this be in Sequelize
I believe this would make the usage of operators easier to read and understand.
Describe alternatives/workarounds you've considered
If using Symbol.toPrimitive feels too much like magic, those functions could be provided somewhere else. Sequelize.and, Sequelize.or, etc already exist.
Additional context
N/A
Feature Request Checklist
Is this feature dialect-specific?
Would you be willing to implement this feature by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: