id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 15304,`Model.objects.create()` returns `long` instead of `int`.,Tai Lee,nobody,"Some database backends (I've only tested postgresql, sqlite seems OK) seem to return a `long` PK instead of `int` when creating new model objects. When getting an existing model object, `int` is correctly returned. I did find a comment about this in the [http://docs.djangoproject.com/en/dev/intro/tutorial01/#creating-models tutorial], but I don't think this is by design and I think this difference in behaviour between new and existing objects and database backends is buggy and violates the principle of least surprise. It might be a bit of an edge case, but we were stumped for a while trying to figure out why created objects had a PK of a different type to existing objects. We initially noticed the problem because we use a pickle field to store various types of data -- PKs, dates and times, booleans, dicts, etc. -- and when passing in the value of a newly created PK to the pickle field we were then unable to filter on it unless we explicitly searched for `long` values. So to work-around this issue we need to a) know the type of the PK that should be returned for existing objects and coerce it before passing to the pickle field if it does not match. ",Bug,closed,"Database layer (models, ORM)",dev,Normal,wontfix,int long primary key create get,,Design decision needed,1,0,0,0,1,0