Skip to content
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

Align mongodb4.4 #28

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
71af58a
positional mismatch on 4.4
davidlatwe Apr 27, 2021
991072a
positional non located match on 4.4
davidlatwe Apr 27, 2021
c947bba
fix deprecation warnings
davidlatwe Apr 28, 2021
084b0f9
set 4.4 as compat version
davidlatwe Apr 28, 2021
7ba6a9c
check positional key position
davidlatwe Apr 28, 2021
39c3ba1
update compat attributes
davidlatwe Apr 28, 2021
03f5061
check field not end with "."
davidlatwe Apr 28, 2021
fe7fe31
fix typo from c947bbaa
davidlatwe Apr 28, 2021
bd89b6f
Merge branch 'master' into align-mongodb4.4
davidlatwe May 29, 2021
5a7b9a6
testing mongodb 4.4
davidlatwe May 29, 2021
8e86856
Merge branch 'master' into align-mongodb4.4
davidlatwe Jun 5, 2021
7b50a9e
Merge branch 'master' into align-mongodb4.4
davidlatwe Jun 20, 2021
894e92a
flake8: bump max-complexity
davidlatwe Jun 20, 2021
725b30f
Merge branch 'master' into align-mongodb4.4
davidlatwe Jun 20, 2021
18fa399
project: fix regression
davidlatwe Jun 20, 2021
151c90e
tests: update projection test specific for 4.4
davidlatwe Jun 20, 2021
853286b
Merge branch 'master' into align-mongodb4.4
davidlatwe Jun 26, 2021
6b445e2
Merge branch 'master' into align-mongodb4.4
davidlatwe Jul 2, 2021
ce6a36c
add projection path collision check
davidlatwe Jul 7, 2021
2a99bdd
add $mod remainder check
davidlatwe Jul 7, 2021
318389b
Merge branch 'master' into align-mongodb4.4
davidlatwe Jul 7, 2021
c7a3261
flake8: bump max-complexity, again
davidlatwe Jul 7, 2021
7cdc500
flake8: fix indent (E126)
davidlatwe Jul 7, 2021
3fd4fd9
Merge branch 'master' into align-mongodb4.4
davidlatwe Jan 21, 2023
c3a2faa
Cleanup after master merged
davidlatwe Jan 21, 2023
55224a2
Add mongodb 5.0, 6.0
davidlatwe Jan 22, 2023
0735ebf
Add mongoengine to test; Drop Python 3.6
davidlatwe Jan 22, 2023
fcaa688
Update poetry.lock
davidlatwe Jan 22, 2023
0c3862d
Update poetry.lock
davidlatwe Jan 22, 2023
fe4d6b4
Merge branch 'master' into align-mongodb4.4
davidlatwe Feb 3, 2023
0ba3d5d
Fix query mod regression
davidlatwe Feb 3, 2023
aef4af7
Exclude poetry-version from matrix
davidlatwe Feb 3, 2023
e83e863
Add test cases
davidlatwe Feb 3, 2023
016b62a
Cleanup
davidlatwe Feb 3, 2023
71f8283
Fix warnings in test
davidlatwe Feb 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup after master merged
  • Loading branch information
davidlatwe committed Jan 21, 2023
commit c3a2faaed676fdeb212fd68c2217fee916f0f798
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lint: ## Run linting with flake8
poetry run flake8 . \
--count \
--ignore=F841,W503 \
--max-complexity=26 \
--max-complexity=32 \
--max-line-length=88 \
--statistics \
--exclude .venv
Expand Down
73 changes: 32 additions & 41 deletions montydb/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,50 +292,41 @@ def _bson_init(use_bson):
def _mongo_compat(version):
from .engine import queries, project

def patch(mod, func, ver_func):
setattr(mod, func, getattr(mod, ver_func))
def patch(mod, attr, ver):
setattr(mod, attr, getattr(mod, attr + ver))

if version.startswith("3"):
patch(queries, "_is_comparable", "_is_comparable_ver3")
patch(queries, "_regex_options_check", "_regex_options_")
patch(queries, "_mod_remainder_not_num", "_mod_remainder_not_num_")
patch(queries, "_is_comparable", "_ver3")
patch(queries, "_regex_options", "_")
patch(queries, "_mod_check_numeric_remainder", "_")
patch(project, "_positional_mismatch", "_")
patch(project, "_check_positional_key", "_")
patch(project, "_check_path_collision", "_")
patch(project, "_include_positional_non_located_match", "_")

elif version == "4.0":
patch(queries, "_is_comparable", "_is_comparable_ver4")
patch(queries, "_regex_options_check", "_regex_options_")
patch(queries, "_mod_remainder_not_num", "_mod_remainder_not_num_")
patch(queries, "_is_comparable", "_ver4")
patch(queries, "_regex_options", "_")
patch(queries, "_mod_check_numeric_remainder", "_")
patch(project, "_positional_mismatch", "_")
patch(project, "_check_positional_key", "_")
patch(project, "_check_path_collision", "_")
patch(project, "_include_positional_non_located_match", "_")

elif version == "4.2":
patch(queries, "_is_comparable", "_is_comparable_ver4")
patch(queries, "_regex_options_check", "_regex_options_v42")
patch(queries, "_mod_remainder_not_num", "_mod_remainder_not_num_")

else:
patch(queries, "_is_comparable", "_is_comparable_ver4")
patch(queries, "_regex_options_check", "_regex_options_")
patch(queries, "_mod_remainder_not_num", "_mod_remainder_not_num_v44")

if version == "4.4":
# $mod checking remainder is starting from mongo-4.3.1 but since 4.3 is not
# a stable release so we match this behavior in 4.4
setattr(queries, "_mod_check_numeric_remainder",
getattr(queries, "_mod_check_numeric_remainder_v431_"))
setattr(project, "_positional_mismatch",
getattr(project, "_positional_mismatch_v44"))
setattr(project, "_check_positional_key",
getattr(project, "_check_positional_key_v44"))
setattr(project, "_check_path_collision",
getattr(project, "_check_path_collision_v44"))
setattr(project, "_include_positional_non_located_match",
getattr(project, "_include_positional_non_located_match_v44"))
else:
setattr(queries, "_mod_check_numeric_remainder",
getattr(queries, "_mod_check_numeric_remainder_"))
setattr(project, "_positional_mismatch",
getattr(project, "_positional_mismatch_"))
setattr(project, "_check_positional_key",
getattr(project, "_check_positional_key_"))
setattr(project, "_check_path_collision",
getattr(project, "_check_path_collision_"))
setattr(project, "_include_positional_non_located_match",
getattr(project, "_include_positional_non_located_match_"))
patch(queries, "_is_comparable", "_ver4")
patch(queries, "_regex_options", "_v42")
patch(queries, "_mod_check_numeric_remainder", "_")
patch(project, "_positional_mismatch", "_")
patch(project, "_check_positional_key", "_")
patch(project, "_check_path_collision", "_")
patch(project, "_include_positional_non_located_match", "_")

else: # 4.4+ (default)
patch(queries, "_is_comparable", "_ver4")
patch(queries, "_regex_options", "_")
patch(queries, "_mod_check_numeric_remainder", "_v431_")
patch(project, "_positional_mismatch", "_v44")
patch(project, "_check_positional_key", "_v44")
patch(project, "_check_path_collision", "_v44")
patch(project, "_include_positional_non_located_match", "_v44")
17 changes: 2 additions & 15 deletions montydb/engine/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def _regex_options_v42(regex_flag, opt_flag):
raise OperationFailure("options set in both $regex and $options")


_regex_options_check = _regex_options_v42
_regex_options = _regex_options_v42


def _modify_regex_optins(sub_spec):
Expand Down Expand Up @@ -451,7 +451,7 @@ def _modify_regex_optins(sub_spec):
_re = sub_spec["$regex"]
sub_spec["$regex"] = None

_regex_options_check(regex_flags, opt_flags)
_regex_options(regex_flags, opt_flags)

new_sub_spec = deepcopy(sub_spec)
new_sub_spec["$regex"] = {
Expand Down Expand Up @@ -897,18 +897,6 @@ def _regex(fieldwalker):
return _regex


def _mod_remainder_not_num_():
pass


def _mod_remainder_not_num_v44():
# https://jira.mongodb.org/browse/SERVER-23664
raise OperationFailure("malformed mod, remainder not a number")


_mod_remainder_not_num = _mod_remainder_not_num_v44


_mod_check_numeric_remainder_ = False
_mod_check_numeric_remainder_v431_ = True
_mod_check_numeric_remainder = _mod_check_numeric_remainder_v431_
Expand All @@ -930,7 +918,6 @@ def parse_mod(query):
if not isinstance(divisor, num_types):
raise OperationFailure("malformed mod, divisor not a number")
if not isinstance(remainder, num_types):
# _mod_remainder_not_num()
if _mod_check_numeric_remainder:
raise OperationFailure("malformed mod, remainder not a number")
remainder = 0
Expand Down
3 changes: 0 additions & 3 deletions tests/test_engine/test_queries/test_queryop_evaluation_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
from montydb.errors import OperationFailure as monty_op_fail
from montydb.types import bson

from pymongo.errors import OperationFailure as MongoOpFail
from montydb.errors import OperationFailure as MontyOpFail

from ...conftest import skip_if_no_bson


Expand Down