200 Commits

Author SHA1 Message Date
Ross Lawley
4b9bacf731 Added ComplexBaseField
* Handles the efficient lazy dereferencing of DBrefs.
* Handles complex nested values in ListFields and DictFields
* Allows for both strictly declared ListFields and DictFields where the embedded
value must be of a field type or no restrictions where the values can be a mix
of field types / values.
* Handles DBrefences of documents where allow_inheritance = False.
2011-06-09 11:25:24 +01:00
Colin Howe
4174918476 Merge in upstream dev 2011-06-08 12:33:36 +01:00
Colin Howe
7c62fdc0b8 Allow for types to never be auto-prepended to indices 2011-06-08 12:20:58 +01:00
Ross Lawley
3c88faa889 Updated slave_okay syntax
Now inline with .timeout() and .snapshot().
Made them chainable - so its easier to use and added tests for cursor_args
2011-06-08 12:06:26 +01:00
Ross Lawley
d15f5ccbf4 Added _slave_okay to clone 2011-06-08 10:41:08 +01:00
Ross Lawley
55e20bda12 Added slave_okay syntax to querysets.
* slave_okay (optional): if True, allows this query to be run against a replica secondary.
2011-06-06 14:35:46 +01:00
Ross Lawley
56f00a64d7 Added bulk insert method.
Updated changelog and added tests / query_counter tests
2011-06-06 12:37:06 +01:00
Colin Howe
40df08c74c Fix QuerySet.ensure_index for new index specs 2011-05-29 13:33:00 +01:00
Colin Howe
1fa47206aa Support for sparse indexes and omitting types from indexes 2011-05-26 19:39:41 +01:00
Ross Lawley
c903af032f Added inline_map_reduce functionality
Also added map_reduce method for calculating item_frequencies
Closes #183
2011-05-26 15:44:43 +01:00
Ross Lawley
60c8254f58 Tweaks to item_frequencies
Updated to use a ternary statement and added tests
Refs #124 #122

Thanks to @nickvlku for the code.
2011-05-25 11:10:42 +01:00
Ross Lawley
2ce70448b0 Merge branch 'dev' into pull_124 2011-05-25 09:54:56 +01:00
Alistair Roche
305fd4b232 Fixed whitespace 2011-05-24 11:44:43 +01:00
Alistair Roche
fe5111743d Merge branch 'dev' into feature/update_lists
Conflicts:
	mongoengine/queryset.py
2011-05-24 11:33:44 +01:00
Alistair Roche
8427877bd2 Merge remote branch 'upstream/dev' into dev 2011-05-24 11:32:23 +01:00
Alistair Roche
118c0deb7a Fixed list-indexing syntax; created tests. 2011-05-24 11:31:44 +01:00
Ross Lawley
1126c85903 Added Custom Objects Managers
Managers can now be directly declared in a Document eg::

```python
    class CustomQuerySetManager(QuerySetManager):

        @staticmethod
        def get_queryset(doc_cls, queryset):
            return queryset(is_published=True)

    class Post(Document):
        is_published = BooleanField(default=False)
        published = CustomQuerySetManager()
```

Refactored the name of the `_manager_func` to `get_queryset` to mark it as
part the public API.  If declaring a Manager with a get_queryset method, it
should be a staticmethod, that accepts the document_class and the queryset.

Note - you can still use decorators in fact in the example below,
we effectively do the same thing as the first example and is much less verbose.

```python

    class Post(Document):
        is_published = BooleanField(default=False)

        @queryset_manager
        def published(doc_cls, queryset):
            return queryset(is_published=True)
```

Thanks to @theojulienne for the initial impetus and code sample #108
2011-05-24 11:26:46 +01:00
Alistair Roche
13935fc335 Merge branch 'dev' into feature/update_lists 2011-05-24 08:58:38 +01:00
Alistair Roche
36034ee15f 'set__comments__0__body="asdf"' syntax works 2011-05-23 18:27:01 +01:00
Ross Lawley
04953351f1 Merge branch 'feature/slicing_fields' into dev 2011-05-20 14:18:48 +01:00
Ross Lawley
08d1689268 Updated to handle the converntional api style for slicing a field
Added testcase to demonstrate embedded slicing as well.

Refs #167
2011-05-20 09:47:41 +01:00
Ross Lawley
40b69baa29 Implementing Write Concern
Added write_options dict to save, update, update_one and get_or_create.
Thanks to justquick for the initial ticket and code.

Refs #132
2011-05-19 16:49:00 +01:00
Ross Lawley
fc2aff342b Unique indexes are created before user declared indexes
This ensures that indexes are created with the unique flag, if a user
declares the index, that would automatically be declared by the `unique_indexes`
logic.

Thanks to btubbs for the test case.
Fixes #129
2011-05-18 17:37:41 +01:00
Ross Lawley
371dbf009f Updated QuerySet to allow more granular fields control.
Added a fields method and tests showing the retrival of subranges of
List Fields.

Refs #167
2011-05-18 16:39:19 +01:00
Ross Lawley
5d5a84dbcf Spacing issue cleaned up 2011-05-18 16:24:35 +01:00
Ross Lawley
7ba40062d3 Fixes ordering with custom db field names
Closes #125
2011-05-18 12:18:33 +01:00
Ross Lawley
31521ccff5 Added queryset clone support and tests, thanks to hensom
Fixes #130
2011-05-18 10:30:07 +01:00
Ross Lawley
e3b4563c2b Merge remote branch 'hensom/master' into dev 2011-05-18 10:06:16 +01:00
Ross Lawley
98436f271e Merge branch 'master' into dev 2011-05-18 08:13:58 +01:00
Matt Chisholm
608f08c267 Implement spherical geospatial query operators & unit tests
fixes https://github.com/hmarr/mongoengine/issues/163
2011-05-10 12:28:56 +02:00
Ross Lawley
f0277736e2 Updated queryset to handle latest version of pymongo
map_reduce now requires an output.
Reverted previous _lookup_field change, until a test case
is produced for the incorrect behaviour.
2011-05-09 10:22:37 +01:00
Alistair Roche
76cbb66843 Fixed error with _lookup_field
It was failing when given multiple fields
2011-04-28 14:31:19 +01:00
Harry Marr
69171282e9 Merge branch 'master' of https://github.com/lig/mongoengine into dev
Conflicts:
	.gitignore
2011-03-06 13:11:21 +00:00
Michael Henson
53d66b7267 Added QuerySet.clone() to support copying querysets 2011-01-27 23:51:10 -05:00
Nick Vlku
ba9813e5a3 Fixed Issue 122: item_frequencies doesn't work if tag is also the name of a native js function
Did this by checking if the item is a native function, if it is I set it to an initial numeric value.  Future occurrences of the tag count correctly.
2011-01-09 22:30:18 -05:00
Harry Marr
ce8b3ea0a1 Merge remote branch 'nvie/dev' into dev 2011-01-09 23:29:11 +00:00
Harry Marr
10c0b035ae Merge remote branch 'aleszoulek/dev' into dev 2011-01-09 23:19:41 +00:00
Harry Marr
357dd0e7cc Merge remote branch 'iapain/master' into dev 2011-01-09 20:52:39 +00:00
Serge Matveenko
34b923b7ac Fix Issue#115: Possibility to bypass class_name check in queryset. 2010-12-21 18:29:51 +03:00
Vincent Driessen
e05e6b89f3 Add safe_update parameter to updates. 2010-12-16 11:54:34 +01:00
Vincent Driessen
f30fd71c5e Refactor: put the delete rule constants into the queryset module, too. 2010-12-13 13:42:01 -08:00
Vincent Driessen
07dae64d66 More the deletion code over to the QuerySet object.
The Document object doens't have any delete_rule specific code anymore,
and leverages the QuerySet's ability to deny/cascade/nullify its
relations.
2010-12-13 12:36:24 -08:00
Harry Marr
3a0523dd79 Fixed issue with unset operation 2010-12-05 21:43:04 +00:00
Ales Zoulek
66baa4eb61 QS.all_fields - resets previous .only() and .exlude() 2010-11-10 22:01:27 +01:00
Deepak Thukral
89646439e7 fixed typo in error message 2010-11-10 21:02:59 +01:00
Ales Zoulek
bda4776a18 added Queryset.exclude() + tests 2010-11-05 12:57:48 +01:00
Harry Marr
c6058fafed Merge branch 'dev' of github.com:hmarr/mongoengine into dev 2010-11-02 13:44:19 +00:00
Harry Marr
11950eabea Merge branch 'master' of http://github.com/aleszoulek/mongoengine into dev 2010-11-02 13:43:33 +00:00
Harry Marr
6b880aa8b3 Fixed order-then-filter issue 2010-11-01 00:43:30 +00:00
Ales Zoulek
a3830be4c9 QuerySet.only() supports subfields + tests 2010-10-28 01:13:24 +02:00