Open ftcmnc opened 9 years ago
MongoDB object IDs are 12 bytes and will not fit into an 8 byte integer. Problem is in gluon/tools.py at line 2081:
db.define_table(
settings.table_permission_name,
Field('group_id', reference_table_group,
label=self.messages.label_group_id),
Field('name', default='default', length=512,
label=self.messages.label_name,
requires=is_not_empty),
Field('table_name', length=512,
label=self.messages.label_table_name),
Field('record_id', 'integer', default=0, # field type is wrong for MongoDB
label=self.messages.label_record_id,
requires=IS_INT_IN_RANGE(0, 10 ** 9)),
Specifically 'record_id' type should likely be 'id' not 'integer'. Also the requires clause will need a wider range. Changing this field to 'id' fixes the problem in my tests on Mongo, but I have no easy way to know how it would impact other databases.
I don't how or if this bug can be moved over to web2py.
I think this is web2py related and not pydal. @mdipierro ?
@stephenrauch switching the type to 'id' is not feasible for all adapters. For example on postgres the type 'id' is converted into a SERIAL PRIMARY KEY
.
Switching to 'id' works with mondo because such fields are converted in object_id by the mongo adapter
@ilvalle ok, but still I think is web2py related and not pydal related.
Being new to pydal, let me see if I understand the design:
I have this
that produces this error:
<type 'exceptions.OverflowError'> MongoDB can only handle up to 8-byte ints
Version
Traceback
It was working well on the previous version