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
JS: Add generated typings to SQL models #10253
Merged
Merged
+3,693
−862
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6ffbbba
to
fe16a73
Compare
efe1273
to
112abba
Compare
8cb6f54
to
bc6741f
Compare
erik-krogh
reviewed
Sep 22, 2022
javascript/ql/test/library-tests/frameworks/SQL/SqlString.expected
Outdated
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
This refactors most of the SQL and NoSQL models to rely on MaD type-definitions generated from
.d.tsfiles from their respective libraries.Most of the infrastructure behind this was merged in #10205 and #10206.
Model.json files
Each MaD model lives in a folder containing a
model.jsonandModel.qllfile. The.qllfile is entirely generated from the.jsonfile and isn't something you'd normally look at.Some information about the
model.jsonfiles:generatedModelfield contains CSV rows entirely generated by madman, which can be regenerated from the rest of the file. It only contains type definitions and type variables (no sources and sinks).modelfield contains user-maintained CSV rows to be merged with those fromgeneratedModel. Anything added via the interactive mode inmadmangets added here as well (i.e. sinks).usedTypesfield listspackage;typepairs that should be considered relevant (i.e. not pruned), since we expect to use from fromModelOutput::getATypeNodereplaceTypeParametersfield identifies type parameters that should be seen as an alias for another type. This can help deal with typings that are parameterized in ways that we don't care about.Comparison to hand-written models
The initial version of the generated models were not a perfect improvement over hand-written models, as both models covered some cases that were missing in the other one (due to incomplete typings). I manually added the missing parts to the
modelsection, or via thereplaceTypeParametersfeature, to ensure a final model that covers everything.Previously we'd have roughly one predicate per type we cared about, for example,
Now, only the last clause is relevant. Simply doing
API::Node::ofType("mongodb", "Collection")should give everything from the above, because the MaD tables contain the information previously hand-written in the bodies of these predicates.Evaluations
Evaluation 1 and Evaluation 2 cover 200 projects that depend on various SQL/NoSQL libraries, and show in total: