Skip to content

Incorrect conversion of numeric return values  #8

Closed
@sris

Description

@sris

Currently all values will be converted using int or float_fn in _get_value if it's possible.
This is done regardless of what was actually put in.
This can lead to some hard to spot errors.

Example

v1 = "1234567" # E.g. hash values or something "non controllable"
v2 = "1ab3dc8"
type(v1), v1, type(v2), v2 => (<type 'str'>, '1234567', <type 'str'>, '1ab3dc8')

redis.Redis().set("a", v1)
redis.Redis().set("b", v2)

v1 = redis.Redis().get("a")
v2 = redis.Redis().get("b")
type(v1), v1, type(v2), v2 => (<type 'int'>, 1234567, <type 'unicode'>, u'1ab3dc8')

As you can see the returned values no longer match in type. It's not very intuitive that some values automatically gets converted while other doesn't.

I think it would be more appropriate to always return the non converted values, unless, if made possible, some other type where explicitly provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions