Nigel McNie
4c9e90732e
Apply defaults to fields with None value at 'set' time.
...
If a field has a default, and you explicitly set it to None, the
behaviour before this patch was very confusing:
class Person(Document):
created = DateTimeField(default=datetime.datetime.utcnow)
>>> p = Person(created=None)
>>> p.created
datetime.datetime(2013, 5, 30, 0, 18, 20, 242628)
>>> p.created
datetime.datetime(2013, 5, 30, 0, 18, 20, 995248)
>>> p.created
datetime.datetime(2013, 5, 30, 0, 18, 21, 370578)
It would be stored as None, and then at 'get' time, the default would be
applied. As you can see, if the default is a generator, this leads to some
crazy behaviour.
There's an argument that if I asked it to be set to None, why not respect that?
But I don't think that's how the rest of mongoengine seems to work (for
example, setting a field to None seems to mean it doesn't even get set in mongo
- as opposed to being set but with a 'null' value). Besides, as the code shows
above, you'd expect p.created to return None. So clearly, mongoengine is
already expecting None to mean 'default' where a default is available.
This bug also interacts nastily with required=True - if you're forcibly setting
the field to None, then at validation time, the None will fail validation
despite a perfectly valid default being available.
With this patch, when the field is set, the default is immediately applied.
This means any generation happens once, the getter always returns the same
value, and 'required' validation always respects the default.
Note: this breakage seems to be new since mongoengine 0.8.
2013-05-30 16:37:40 +12:00
Ross Lawley
c5ce96c391
Fix py3 test
2013-05-23 19:44:05 +00:00
Ross Lawley
b4a98a4000
More upgrade clarifications #331
2013-05-23 19:30:57 +00:00
Ross Lawley
5f0d86f509
Upgrade doc fix ( #330 )
2013-05-23 19:12:13 +00:00
Ross Lawley
c96a1b00cf
Documentation cleanup ( #328 )
2013-05-23 19:09:05 +00:00
Ross Lawley
1eb6436682
Added get image by grid_id example
2013-05-22 10:29:45 +00:00
Ross Lawley
a84e1f17bb
Fixing django tests for py 2.6
2013-05-21 09:42:22 +00:00
Ross Lawley
3ffc9dffc2
Updated requirements for test suite
v0.8.1
2013-05-21 09:37:22 +00:00
Ross Lawley
048c84ab95
Merge branch 'master' of github.com:MongoEngine/mongoengine
2013-05-21 09:12:38 +00:00
Ross Lawley
a7470360d2
Version bump
2013-05-21 09:12:09 +00:00
Ross Lawley
50f1ca91d4
Updated Changelog
2013-05-21 09:05:55 +00:00
Ross Lawley
0d37e1cd98
Merge pull request #326 from mitar/importlib-python26
...
importlib does not exist on Python 2.6. Use Django version.
2013-05-21 00:19:29 -07:00
Ross Lawley
9aa77bb3c9
Fixed pickle unsaved document regression ( #327 )
2013-05-21 07:07:17 +00:00
Ross Lawley
fd11244966
Merge pull request #327 from elasticsales/pickle-error
...
Document is not picklable before it is saved
2013-05-21 00:05:00 -07:00
Stefan Wojcik
d060da094f
update pickling test case to show the error
2013-05-20 17:40:56 -07:00
Mitar
306f9c5ffd
importlib does not exist on Python 2.6. Use Django version.
2013-05-20 17:30:41 -07:00
Ross Lawley
5ef5611682
0.8.0 is a go
v0.8.0
2013-05-20 12:34:47 +00:00
Ross Lawley
ebdd2d730c
Fixed querying ReferenceField custom_id ( #317 )
2013-05-20 10:20:43 +00:00
Ross Lawley
1ddf8b3159
Merge remote-tracking branch 'origin/pr/317'
2013-05-20 10:20:04 +00:00
Ross Lawley
a6bc870815
Fixed pickle issues with collections ( #316 )
2013-05-20 10:10:53 +00:00
Ross Lawley
56cd73823e
Add backwards compat for pickle
2013-05-20 10:09:16 +00:00
Ross Lawley
6299015039
Updated pickling ( #316 )
2013-05-20 10:04:17 +00:00
Ross Lawley
11b7cfb5ff
Merge remote-tracking branch 'origin/pr/316' into 316
2013-05-20 09:08:12 +00:00
Ross Lawley
367f49ce1c
Updated changelog
2013-05-20 08:12:50 +00:00
Ross Lawley
8165131419
Doc updated
2013-05-20 08:12:09 +00:00
Ross Lawley
e402157b4d
Merge remote-tracking branch 'origin/pr/319'
2013-05-20 08:10:37 +00:00
Ross Lawley
967da7944f
Merge branch 'master' of github.com:MongoEngine/mongoengine
2013-05-20 08:09:30 +00:00
Ross Lawley
89f1c21f20
Updated AUTHORS ( #325 )
2013-05-20 08:08:52 +00:00
Ross Lawley
7e706190a5
Merge pull request #325 from daxtens/doc-fixes
...
Minor documentation fix: switch_collection -> switch_db for changing database
2013-05-20 01:07:39 -07:00
Daniel Axtens
36a3770673
If you need to read from another database, use switch_db not switch_collection.
2013-05-20 15:49:01 +10:00
Wilson Júnior
bc92f78afb
fixes for value_decorator
2013-05-16 13:12:49 -03:00
Wilson Júnior
f7e22d2b8b
fixes for get_next_value
2013-05-16 13:05:07 -03:00
Wilson Júnior
0b1e11ba1f
added my github profile
2013-05-16 12:55:16 -03:00
Wilson Júnior
10e0b1daec
Merge branch 'master' of https://github.com/MongoEngine/mongoengine
2013-05-16 12:50:47 -03:00
Wilson Júnior
731d8fc6be
added get_next_value to SequenceField
2013-05-16 12:50:34 -03:00
Stefan Wojcik
f6d0b53ae5
test reference to a custom pk doc
2013-05-13 21:42:20 -07:00
Léo S
0efb90deb6
Added a failing test when using pickle with signal hooks
2013-05-13 13:14:15 +02:00
Ross Lawley
b16eabd2b6
Updated version
2013-05-10 15:09:08 +00:00
Ross Lawley
f8350409ad
assertEquals is bad
2013-05-10 15:08:01 +00:00
Ross Lawley
5b498bd8d6
Added no_sub_classes context manager and queryset helper ( #312 )
2013-05-10 15:05:16 +00:00
Ross Lawley
941042d0ba
Merge remote-tracking branch 'origin/pr/312' into 312
2013-05-10 14:44:44 +00:00
Ross Lawley
9251ce312b
Querysets now utilises a local cache
...
Changed __len__ behavour in the queryset (#247 , #311 )
2013-05-10 13:57:32 +00:00
Wilson Júnior
96a964a183
added .disable_inheritance method for the simple fetch exclusives classes
2013-05-09 13:18:58 -03:00
Ross Lawley
9e513e08ae
Updated RC version
2013-05-07 11:55:56 +00:00
Ross Lawley
9dfee83e68
Fixed querying string versions of ObjectIds issue with ReferenceField ( #307 )
2013-05-07 11:54:47 +00:00
Ross Lawley
7cde979736
Updated fields
2013-05-07 11:39:16 +00:00
Ross Lawley
870ff1d4d9
Added $setOnInsert support for upserts ( #308 )
...
Upserts now possible with just query parameters (#309 )
2013-05-07 11:11:55 +00:00
Ross Lawley
52c162a478
Pep8
2013-05-07 11:01:23 +00:00
Ross Lawley
ddd11c7ed2
Added offline docs links
2013-05-07 10:57:52 +00:00
Ross Lawley
2c119dea47
Upserting is the only way to ensure docs are saved correctly ( #306 )
2013-05-07 10:34:13 +00:00