fix: precise 規則的讀取順序被 rule_str 排序打亂了 - #40
Open
chiakich wants to merge 1 commit into
Open
Conversation
chiakich
force-pushed
the
fix/precise-rule-order
branch
from
August 12, 2026 02:23
53f40d2 to
81a14a2
Compare
chiakich
force-pushed
the
fix/precise-rule-order
branch
2 times, most recently
from
August 12, 2026 02:29
c522f0f to
3346834
Compare
chiakich
force-pushed
the
fix/precise-rule-order
branch
from
August 12, 2026 02:32
3346834 to
810a2b3
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
@moskytw 感謝您製作的套件,多年以來一直使用,受益良多,非常感謝!但最近發現一個 bug:
問題
get_rule_str_zipcode_pairs()查詢沒有order by,SQLite 因此透過(addr_str, rule_str)主鍵索引取列,等於照rule_str字碼排序。但find()是 first-match-wins,規則順序即比對優先序,跟字碼順序無關。全這種整條路的 catch-all 字碼排序會排在單/連/雙之前,於是蓋掉本來要墊底的窄範圍規則:這應該跟 #17 當年回報的是同一個 bug(
興大路145號答成整區碼),只是被誤診為個案。修法
select ... order by rowid。precise是一般 rowid table 靠insert or ignore灌入,rowid 即 CSV 列序,也就是中華郵政資料本身「特例在前、全在後」的順序。測試
在
TestDirectory的 CSV fixture 加了一段可重現此問題的測試街道,並新增test_find_prefers_narrower_rule_over_catch_all。還原修正可讓新測試失敗,套用後通過,已手動驗證。