Issue #20 new

Using Coerce(long) in range key fails

Alan Descoins
created an issue

Hi,

When using a schema such that

    __schema__ = {
        ...
        u'range_key': Coerce(long),
        ...
    }

On create_table, the _get_proto_value function fails with

TypeError: long() argument must be a string or a number, not 'NoneType'

Is this an error on my part? Am I doing wrong for using Coerce here?

Thanks!

Comments (3)

  1. Max Noel

    It's a bug indeed, good catch. You'll get an error with Coerce on any type that can't be instantiated from None. I'm going to look for a clean fix.

    Please note that Coerce(long) is only useful if you want to be able to convert strings or floats to longs (so, assigning stuff like u"123" or 0.4 to your range key, resulting in 123 and 0 respectively). Promotion between ints and longs is handled transparently and automatically, so if that's what you were using Coerce(long) for you can simply mention int or long as a type in your schema, getting rid of the Coerce entirely.

  2. Log in to comment