-
Notifications
You must be signed in to change notification settings - Fork 53
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
Datastore Key type error when using cache #243
Comments
Thank you for the feedback @superwoou can you please add a code snippet so that we can recreate the issue? This will ensure that we properly resolve the issue and we can update our unit tests to ensure that the issue is properly addressed. Ideally something like:
What we would want to do is update the integration tests with a test to recreate this - https://github.com/sebelga/gstore-node/blob/master/__tests__/integration/cache.ts. |
Sorry for late reply. Oh, I added a code snippet to reproduce. datastore.js
model.js
test.js
I add logging on responseHandler Line 157 in b87a275
I found the difference is type of key. (I said in original issue post). console.log(e[this.Model.gstore.ds.KEY]);
When the data is from datastore - I think there are some problem on load result of query from cache. |
I noticed the same issue. Did you find out any resolution/workaround for this problem? @superwoou |
There are two simple workarounds.
I think best way to fix this issue is casting to datastore key after retrieve from cache. |
@superwoou thank you for the workarounds and suggestions. I'll look at
implementing a fix as soon as I have some spare time.
On Thu, 29 Jul 2021 at 09:25, superwoou ***@***.***> wrote:
I noticed the same issue. Did you find out any resolution/workaround for
this problem? @superwoou <https://github.com/superwoou>
There are two simple workarounds.
1. Disable cache on findOne
2. Make function by list
await User.findOne({ username: 'test' }, null, null, { cache: false });
function findOne(model, filters) {
const {entities} = await model.list({ filters, limit: 1 });
return entities[0];
}
I think best way to fix this issue is casting to datastore key after
retrieve from cache.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#243 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPXZJQDWU2PU2HTWAGVYXDT2D66LANCNFSM4XV4USUQ>
.
--
---
s: 083 647 7674
w: http://sudo.org.za
in: http://linkedin.com/in/carnun
tw: http://twitter.com/carnun
fb: http://www.facebook.com/carnun
|
When i try to get entity by model.list, there is same error on convert entity from cache (Error: Entity Key must be a Datastore Key) |
Sorry for the long wait, thank you for all the feedback and suggestions. I just released the v7.2.8 which includes an integration test to verify the issue. |
…aded from cache All entities which have id based keys now return those ids and their paths as numbers. If you rely on the id being a string you will need to update your code. BREAKING CHANGE: Entity keys return ids as Number fix #243
…aded from cache All entities which have id based keys now return those ids and their paths as numbers. If you rely on the id being a string you will need to update your code. BREAKING CHANGE: Entity keys return ids as Number fix #243
* fix(datastore.ts): ensure entities with id based keys are correcly loaded from cache All entities which have id based keys now return those ids and their paths as numbers. If you rely on the id being a string you will need to update your code. BREAKING CHANGE: Entity keys return ids as Number fix #243 * "chore(release): 8.0.0" * docs(changelog): add known Date caching issue
I'm using gstore-node 7.2.5 with cache-manager-redis-store.
When I using
findOne
method, it returns error with cached object.The error message is :
ERROR Entity Key must be a Datastore Key - Error: Entity Key must be a Datastore Key
The problem is that the key with cached object is not Key class, just object.
Without cache :
With cache:
I think gstore-node should convert key property to Key class.
The text was updated successfully, but these errors were encountered: