redis / redis-om-node

Object mapping, and more, for Redis and Node.js. Written in TypeScript.
MIT License
1.18k stars 80 forks source link

Loading empty `string[]` field type #180

Closed jhmaster2000 closed 1 year ago

jhmaster2000 commented 1 year ago

I have a string[] typed field in my redis-om schema, and the arrays can vary in length, including 0.

However I am facing an issue where saving an entity with the field set to [] will work fine, but when loading the entity back, it gets loaded as [""], with an empty string in the place of the 1st index.

This completely disrupts all kinds of array length based checks such as if (entity.array.length === 0) and introduces nasty silent bugs, especially since as far as I can see this is not documented anywhere if it is intended behavior for whatever reason.

So could this either be fixed, or if its intentional, explained why and documented somewhere common so it doesn't catch people off-guard at least?

Extra details: I am using redis-om 0.4.0-beta.3 on Node.js 19.9.0 with HASH schemas (my Redis instance does not have modules)

guyroyse commented 1 year ago

Sounds like a bug. I’ll look into early next week.

guyroyse commented 1 year ago

Also, thanks for the extra detail. I’m 90% sure I know what the problem is.

guyroyse commented 1 year ago

This hasn't fallen off my radar. I've been on the road for the last five weeks. Should have time early next week when I'm in Oslo to work on this. Thanks for you patience.