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

Allow searching for missing custom data properties #2626

Merged
merged 2 commits into from
Sep 1, 2023

Conversation

abdnh
Copy link
Collaborator

@abdnh abdnh commented Aug 28, 2023

This extends prop:cdn to support searching for missing properties using something like prop:cdn:r=none.

Context: https://forums.ankiweb.net/t/more-flags-add-flags-with-custom-names-and-colors/33661/4

@dae
Copy link
Member

dae commented Aug 29, 2023

Hmm. If we introduce a way to search for strings as well in the future (#2627), this would presumably need to be done there too. What do you think about having some separate query like has-cd:foo? Hopefully it would make things a bit simpler. Apologies for only thinking about this after you'd already done the work. :-(

@abdnh
Copy link
Collaborator Author

abdnh commented Aug 29, 2023

What do you think about having some separate query like has-cd:foo?

Sounds reasonable. Will look into that.

@abdnh
Copy link
Collaborator Author

abdnh commented Aug 31, 2023

I implemented this using yet another SQL function. Should we maybe add a general extract_custom_data function and remove extract_custom_data_number?

@dae
Copy link
Member

dae commented Sep 1, 2023

Code changes look good.

I'm ok with using a single extract_custom_data function that just returns strings. It would lead to possibly confusing ordering on values that were supposed to be numeric but weren't, but that's probably not a big deal. I think we'll need to keep the cdn search though, as we'll get different results with numbers and strings:

sqlite> select 1 < 3;
1 < 3 = 1
sqlite> select '1' < 3;
'1' < 3 = 0

Maybe cdn could be rewritten to do the equivalent of this?

sqlite> select cast('1' as float) < 3;
cast('1' as float) < 3 = 1

@dae dae merged commit 064b973 into ankitects:main Sep 1, 2023
@abdnh abdnh deleted the cdn-none branch September 3, 2023 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants