This repository was archived by the owner on Nov 26, 2026. It is now read-only.
Repository navigation
fix(deserialize): call pyutil_mongo.db_find_one in deserialize_board_summary - #25
Open
PttCodingMan wants to merge 1 commit into
Open
PttCodingMan wants to merge 1 commit into
PttCodingMan wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
這個 PR 的目的 / Purpose of this PR
deserialize_board_summary()在沒有傳入read_map時,會呼叫pyutil_mongo.find_one(...),但pyutil_mongo並沒有這個函式(正確名稱是db_find_one),因此這條路徑一定會丟出AttributeError。本 PR 改成呼叫pyutil_mongo.db_find_one。db_find_one找不到資料時回傳{},所以後面的.get('update_milli_ts', 0)可以正常運作。When
deserialize_board_summary()is called withoutread_map, it callspyutil_mongo.find_one(...), which does not exist inpyutil_mongo(the function isdb_find_one). That code path always raisedAttributeError. This PR callspyutil_mongo.db_find_oneinstead; it returns{}when no document matches, so the following.get('update_milli_ts', 0)works.驗證 / Verification
環境:Python 3.10 venv,依
setup.py安裝 Flask-Security-Too 3.4.4、flask-mongoengine 1.0.0 等(另外 pinmongoengine==0.20.0、pymongo<4),測試使用 mongomock,不需要真的 MongoDB。nose1.3.7 在 Python 3.10 無法執行,所以改用pytest<8並以暫時的conftest.py(不 commit)呼叫tests.setup()。Environment: Python 3.10 venv with the
setup.pydependencies (plusmongoengine==0.20.0,pymongo<4); tests use mongomock, no real MongoDB needed.nose1.3.7 does not run on Python 3.10, so I usedpytest<8with a temporary, uncommittedconftest.pythat callstests.setup().新增的回歸測試
test_deserialize_board_summary_without_read_map,在修正前失敗:AttributeError: module 'pyutil_mongo' has no attribute 'find_one'修正後
python -m pytest -q tests:50 passedThe new regression test
test_deserialize_board_summary_without_read_mapfails before the fix withAttributeError: module 'pyutil_mongo' has no attribute 'find_one'.After the fix,
python -m pytest -q tests:50 passed.相關的 issue / Related Issues
無 / None