Coder Social home page Coder Social logo

Comments (8)

mranney avatar mranney commented on May 26, 2024

No, I just ran into this exact situation in my own app, and it's annoying. I'll fix it soon. Thanks for reporting.

from node-redis.

pietern avatar pietern commented on May 26, 2024

Shouldn't this behave just as an empty multi bulk returning an empty array?

from node-redis.

mranney avatar mranney commented on May 26, 2024

It's tricky, because JavaScript considers the empty object to be "truthy".

Now that I think about it though, returning null in this case will break people who do Object.keys(res). Hmm, hard to say which is best.

from node-redis.

pietern avatar pietern commented on May 26, 2024

HGETALL always returns a multi bulk with length >= 0 and error replies are given via the error argument. This implies that you would be able to safely call:

if (result.length)

Right?

from node-redis.

cloudhead avatar cloudhead commented on May 26, 2024

Well, it won't return an error, just an empty set... so the only way to check if it exists is to do if (Object.keys(reply).length), or check if it has a known property.

from node-redis.

cloudhead avatar cloudhead commented on May 26, 2024

If we're trying to be very idiomatic, the current behaviour is best. If we want to be practical, I'd say either error should be non-null, or the reply should be null.

from node-redis.

mranney avatar mranney commented on May 26, 2024

I guess we should just endure the breakage and send back null for an empty reply. Calling Object.keys on an untested value is risky for exactly this reason.

from node-redis.

mranney avatar mranney commented on May 26, 2024

I finally went and landed this change. Sending back null is the less surprising thing, given than JavaScript treats an empty object as truthy.

Apologies to anybody that gets burned by the change in behavior.

from node-redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.