user1151618
user1151618

Reputation:

Mongoengine LongField Overflow Error

I have a Text model;

class Text(db.Document):
    siphash_value = db.LongField()

Then I use siphash lib for create a hash.(https://github.com/majek/pysiphash)

This lib converts string to long value like 12398370950267227270L

If I try save document to my db;

Text(siphash_value=12398370950267227270L).save()

I get this error:

OverflowError: MongoDB can only handle up to 8-byte ints

Upvotes: 1

Views: 2647

Answers (2)

Ross
Ross

Reputation: 18111

MongoDB only supports 64 bit integers (bson.spec) so pymongo can't convert the Long hence the error.

Upvotes: 5

Mauricio Abreu
Mauricio Abreu

Reputation: 155

Could you tell us WHY it is working now? The new library is returning a non long field? (I can not comment your own answer because I have less than 50 reputation, sorry all).

I tried to replace LongField by FloatField and it worked. And actually it has the same result. Just had a different notation (1.2398370950267228e+19).

Upvotes: 0

Related Questions