-
-
Notifications
You must be signed in to change notification settings - Fork 595
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
Add the new fullTextSearch method with the associated tests. #470
Conversation
Codecov Report
@@ Coverage Diff @@
## master #470 +/- ##
==========================================
+ Coverage 84.03% 85.42% +1.39%
==========================================
Files 47 46 -1
Lines 3801 3747 -54
Branches 869 859 -10
==========================================
+ Hits 3194 3201 +7
+ Misses 607 546 -61
Continue to review full report at Codecov.
|
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.
Overall it looks good, but there is some logic in fullTextSearch that either is buggy (if statement that always evaluates to true) or is hard to reason about and warrants test coverage
src/ParseQuery.js
Outdated
fullTextSearch(key: string, search: string, language: string, caseSensitive: boolean, diacriticSensitive: boolean): ParseQuery { | ||
if (typeof key === 'undefined' || !key) { | ||
throw new Error('A key is required.'); | ||
} |
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.
redundant, could be simplified to if(!key)
src/ParseQuery.js
Outdated
throw new Error('You have to add one string to search.'); | ||
} | ||
var options = { '$term': search }; | ||
if (typeof language !== "undefined" || language !== null) { |
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.
inconsistent usage of single/double quoted strings
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.
when is this statement false?
var a = null;
typeof a !== 'undefined' // true
var a = undefined;
a !== null // true
src/ParseQuery.js
Outdated
if (typeof caseSensitive !== "undefined" || caseSensitive !== null) { | ||
options['$caseSensitive'] = caseSensitive; | ||
} | ||
if (typeof diacriticSensitive !== "undefined" || diacriticSensitive !== null) { |
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.
I'm struggling to see when this would ever be falsy
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.
You're right, it was supposed to be a &&
.
To be more precise we could go with something like:
if (typeof diacriticSensitive === "boolean") {
options['$diacriticSensitive'] = diacriticSensitive;
}
I prefer it to just test if (diacritic)
to let user specifies a false
value if he wants to for any reason.
@SebC99 just wanted to check in and see if you're still working on this. For some of the notes above you can simplify them down just |
@montymxb sorry I didn't see @russell-dot-js's comments! I'll check that asap |
c29f31e
to
1012bb0
Compare
if (typeof language === 'string') { | ||
options['$language'] = language; | ||
} | ||
if (typeof caseSensitive === "boolean") { |
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.
Should wrap "boolean"
with single quotes like the ones above.
if (typeof caseSensitive === "boolean") { | ||
options['$caseSensitive'] = caseSensitive; | ||
} | ||
if (typeof diacriticSensitive === "boolean") { |
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.
Same thing here as above
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.
Just some nits with the choice of single/double quotes.
Also can you add integration tests for this? They would go in here. Ideally we'll need a test case demonstrating functional use of each parameter and anti-cases if possible. Just paired cases where one indicates you can find something with fullText and given parameters, and another case where you do not expect to get an object.
As far as the current failure I'll look at this, but it seems unrelated to what you're presenting here.
Other than nice job on putting this together 👍 . Looking forward to checking out the changes!
@SebC99 bump? |
Sorry haven't got the time yet (and not very good at writing tests)! |
Gotcha. Well if you need an idea of what tests would look like you can checkout one of the test files for parse queries. Additionally that example file is probably where you would put your tests as well. Adding some new |
Shit! This did not make it into the JS sdk? |
@srameshr sorry I really don't have the time to add the integration tests for now :( |
@montymxb Any chance that you would make the changes and merge it in? I will update the docs. |
@dplewis It would be great if you could do that. As of now I am manually copying and pasting that chuck of code. |
Sorry guys, I've been a bit busy lately. I'll need to get back on taking a
look at everything here around Thursday or so.
…On Jan 9, 2018 07:09, "Diamond Lewis" ***@***.***> wrote:
@srameshr <https://github.com/srameshr> I wanted to give @SebC99
<https://github.com/sebc99> a chance to get this in. I have some time
later to add Full Text Search to this SDK. That reminds me to add it to the
Android SDK as well.
Also the JS Docs will be auto generated
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#470 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE1d4KMTr_Bw4S2bt017b0u8dWXCRwe4ks5tI4EmgaJpZM4Oqsuy>
.
|
Thanks a lot guys, and sorry for not having had the time to finish it! |
@SebC99 No problem, thanks for getting started on this requested feature. 👍 |
To be used with parse-server version > 2.5.0