Dot notation needed in a few more places #115

Open
ablegrape opened this Issue Mar 17, 2012 · 4 comments

Projects

None yet

4 participants

@ablegrape

I've been using mongodb-engine for a few weeks, now, and overall it works very well (thanks, all).

One of the reasons I chose mongodb is because I have no fixed schema for some of my data, and for a key data structure, one part of each record is a DictField so I can store different fields in each object. This leads me to use dot notation a lot, and I find it works well in some places and, as far as I can tell, doesn't work in others (please correct me if I'm wrong). I couldn't find anything in the docs about what's "supposed to work" versus what doesn't.

Please consider this a feature request for (a) extending "dot notation" to work consistently where it can be made to do so, and (b) clearly documenting the places where it does and doesn't work.

This is by no means a complete list, but here's what I've been noticing (please correct me if I'm wrong and these things do work!):

Doesn't work in:

  • QuerySet filter/exclude/get - makes sense that these wouldn't work, since they use python variable names for parameters. One could imagine overriding the '__' notation, though. I admit that's sort of ugly - and what if a field happens to have the same name as an operator, etc., but despite the exhortation in the docs to avoid using raw_query, I am forced to use it frequently.
  • values(), values_list() - this makes no sense, since these take strings (like order_by(), which works). These are super useful functions (and often necessary to get good performance when pulling just relevant fields out of large records).
@jonashaag

This has been on our agenda for a long time (using the foo__bar syntax) but it requires refactoring of the Django ORM. I have already asked on the django-developers list if this sort of refactoring is welcome but nobody responded so far. Maybe you can bump that thread again :-) http://groups.google.com/group/django-developers/browse_thread/thread/26a3a7eeedc6b605

@ablegrape

Thanks for the quick response, Jonas. I'll check out that thread.

In the mean time, since I have a reasonable workaround (raw_query) for filter/exclude/get, I guess the main issue here is values() and values_list(), which at least from an API perspective could be made to work cleanly (and any other similar functions that may have been left out, though so far only values/values_list() is hitting me on a daily basis).

This being open source, at some point I may have a gander and see if I can fix these things myself, but I've been swamped lately and since I'm new to mongodb-engine and have little experience with Django internals, I suspect the learning curve is steep. So in the mean time if there's someone more "plugged in" who can fix this, it would be super useful.

@ZhangBanger

Is this being worked on? In particular values() and values_list()?

@hackerunet

does anybody have a solution to my issue?

sorry but I'm not using google app engine, just using django-nonrel with djangotoolbox and mongoengine, and I just saw the site you sent and it has no information about what I'm looking for, can you give me a hand on this?
I have this collection in mongo:

{
"_id" : ObjectId("517f00dbe138234abbf790bb"),
"campaigns" : [
{
"payout" : 0.7,
"landing_page" : [ ],
"rotate_urls" : null,
"_module" : "setup.models",
"_model" : "Campaigns",
"cloaking" : true,
"campaign_name" : "DOS",
"rotate_urls_status" : false,
"affiliate_url" : "http://www.DOS.com/[[subid]]"
}
],
"category_name" : "category2"
}

how can I append a embed document into landing_page using django-nonrel, mongoengine without djangodbindexer support?? I have tried this but I always receive errors:
landingpage = LandingPages(nickname=lpnickname,url=lpurl)
b = Categories.objects.get(id=affnetworkid,campaigns__campaign_name=campaignname)
b.landing_page.append(landingpage)
b.save()

The mongoengine documentation says that doble underscore is supported, but, the fact is that django-nonrel or the mongoengine is trying to execute a join which is not what I'm looking for, how can I use dot notation on this??
how can I just add more documents to the landing_page list type inside campaigns???
thanks
note: I have 8 days trying to achieve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment