-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Refactor populate_footprints and get_part_details #511
Conversation
I decided to remove the |
I did a few tests, LIMIT 1 is about 10x faster than using the list comprehension. |
@Bouni agree with removing the limit one and checking the list because I don't see any reason the search is guaranteed to return the exact match first. I wrote a bunch of fts5 tests here that compare the queries etc but haven't cleaned them up for upstream use, and they are in rust. |
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.
Looks "ok" to me although I'm not an fts5 expert. If it works in your testing then its approved by me.
@gonzalop You're right, that was the root problem of PR #503 But that way the method still found hundrets if not thousand results, so no exact match. But then I realized that we have to search the results again in Thanks everybody for helping with all this 👍🏽 |
PR #503 made the plugin way faster but introduced a problem so that no more part details are returned.
The main issue is (as far as may SQLite knowledge goes) that the named parameter was used in a wrong way.
The for loop gernerates a query like this for example, which does not yield any results:
'''SELECT "LCSC Part", "Stock", "Library Type" FROM parts WHERE parts MATCH "LCSC Part:C2286"'''
Fixing that we end up with:
'''SELECT "LCSC Part", "Stock", "Library Type" FROM parts WHERE parts MATCH C2286'''
But that return every LCSC number that includes the searched number.
So limit the reults to 1 like this:
'''SELECT "LCSC Part", "Stock", "Library Type" FROM parts WHERE parts MATCH C2286 LIMIT 1'''
Gives us just the first match, which should give us the search LCSC number only.
I'm not 100% sure about the
LIMIT 1
but it seems to work.@chmorgan Do you know FTS5 good enough that you can verify if theres another way than double quotes do not yield a exact match? (double quotes do not work)