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

getValidator shouldn't try to second-guess a cache key #2540

Open
kapouer opened this issue Oct 11, 2023 · 1 comment
Open

getValidator shouldn't try to second-guess a cache key #2540

kapouer opened this issue Oct 11, 2023 · 1 comment

Comments

@kapouer
Copy link
Contributor

kapouer commented Oct 11, 2023

Following what ajv now does, objection should trust the Map:

const createCacheKey = this.ajvOptions.serialize || JSON.stringify;

It should be something like

let validators = this.cache.get(jsonSchema)

Indeed ajvOptions.serialize now triggers a warning.

Should the team accept it, I'd submit a PR.
This issue won't autodestruct.

@kapouer
Copy link
Contributor Author

kapouer commented Oct 11, 2023

AFAICT the performance is better, since no one will be able to fall for the JSON.stringify trap.
Comparing Map.get(jsonSchema) <-> Map.get(cacheKey) gives the same results.

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

1 participant