-
-
Notifications
You must be signed in to change notification settings - Fork 3
INTPYTHON-348 Update raw_query tests for raw_mql #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INTPYTHON-348 Update raw_query tests for raw_mql #10
Conversation
MongoDB uses ObjectId rather than integer
Looks to be on the right track. |
ba72390
to
7fcf5f0
Compare
tests/raw_query/models.py
Outdated
|
||
|
||
class Author(models.Model): | ||
id = ObjectIdAutoField(primary_key=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to add an explicit primary key to all these methods. Put DEFAULT_AUTO_FIELD = "django_mongodb.fields.ObjectIdAutoField"
in your test settings file.
8a3dabc
to
afbecef
Compare
afbecef
to
f5d38b1
Compare
f5d38b1
to
70ba0a1
Compare
- Fix test_order_handler
- Fix test_query_representation
@@ -247,46 +248,46 @@ def test_query_representation(self): | |||
""" | |||
Test representation of raw query with parameters | |||
""" | |||
query = "SELECT * FROM raw_query_author WHERE last_name = %(last)s" | |||
qset = Author.objects.raw(query, {"last": "foo"}) | |||
query = [{"$match": {"last_name": "%(last)s" % {"last": "foo"}}}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test seems useless if there is no need for a params
argument to raw_mql()
. Using string interpolation to construct the query is not adding any value, so you might just skip test like these if they aren't applicable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand why that would be needed with MQL
or SQL
. There is another test that includes params
kwarg (are we planning to support this?) This one seems to be testing string interpolation for no reason that I understand …
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query parameters are passed separately in SQL-land to protect against SQL injection attacks.
Superseded by #12 |
feature: mongodb/django-mongodb-backend#183