Skip to content

Commit

Permalink
Before Major refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nesdis committed Feb 28, 2020
1 parent 084031a commit bba59a3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
6 changes: 6 additions & 0 deletions djongo/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,9 @@ def bulk_insert_sql(self, fields, placeholder_rows):
'VALUES (%s)' % ', '.join(row)
for row in placeholder_rows
)

def date_extract_sql(self, lookup_type, field_name):
return "EXTRACT('%s' FROM %s)" % (lookup_type, field_name)

def date_trunc_sql(self, lookup_type, field_name):
return "DATE_TRUNC('%s', %s)" % (lookup_type, field_name)
26 changes: 13 additions & 13 deletions djongo/sql2mongo/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,41 +116,41 @@ def parse(self):

while tok_id is not None:
if tok.match(tokens.DML, 'SELECT'):
c = self.selected_columns = ColumnSelectConverter(self, tok_id)
converter = self.selected_columns = ColumnSelectConverter(self, tok_id)

elif tok.match(tokens.Keyword, 'FROM'):
c = FromConverter(self, tok_id)
converter = FromConverter(self, tok_id)

elif tok.match(tokens.Keyword, 'LIMIT'):
c = self.limit = LimitConverter(self, tok_id)
converter = self.limit = LimitConverter(self, tok_id)

elif tok.match(tokens.Keyword, 'ORDER'):
c = self.order = OrderConverter(self, tok_id)
converter = self.order = OrderConverter(self, tok_id)

elif tok.match(tokens.Keyword, 'OFFSET'):
c = self.offset = OffsetConverter(self, tok_id)
converter = self.offset = OffsetConverter(self, tok_id)

elif tok.match(tokens.Keyword, 'INNER JOIN'):
c = InnerJoinConverter(self, tok_id)
self.joins.append(c)
converter = InnerJoinConverter(self, tok_id)
self.joins.append(converter)

elif tok.match(tokens.Keyword, 'LEFT OUTER JOIN'):
c = OuterJoinConverter(self, tok_id)
self.joins.append(c)
converter = OuterJoinConverter(self, tok_id)
self.joins.append(converter)

elif tok.match(tokens.Keyword, 'GROUP'):
c = self.groupby = GroupbyConverter(self, tok_id)
converter = self.groupby = GroupbyConverter(self, tok_id)

elif tok.match(tokens.Keyword, 'HAVING'):
c = self.having = HavingConverter(self, tok_id)
converter = self.having = HavingConverter(self, tok_id)

elif isinstance(tok, Where):
c = self.where = WhereConverter(self, tok_id)
converter = self.where = WhereConverter(self, tok_id)

else:
raise SQLDecodeError

tok_id, tok = self.statement.token_next(c.end_id)
tok_id, tok = self.statement.token_next(converter.end_id)

def __iter__(self):

Expand Down
1 change: 1 addition & 0 deletions tests/django_tests/manage_tests/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

DEFAULT_TESTRUNNER_ARGS = {
'failfast': '--failfast',
'parallel': '--parallel=1'
}

SETTINGS_FILE = {
Expand Down
2 changes: 1 addition & 1 deletion tests/django_tests/manage_tests/tests_list.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ deps =

[testenv:django22_discover]
commands =
python tests/django_tests/manage_tests/runtests.py --discover-passing --django-version=22 --failfast
python tests/django_tests/manage_tests/runtests.py --discover-passing --django-version=22 -v 2
deps =
Django==2.2

Expand Down

0 comments on commit bba59a3

Please sign in to comment.