-
-
Notifications
You must be signed in to change notification settings - Fork 346
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 Indexes via Schema #357
Conversation
Cool! Same deal here as with the aggregate queries. Once the server side functionality is in I'll go over this. |
@montymxb I added documentation and fixed the tests. The test weren't working locally at first until I updated my version of node from 6.10 to 9.2. I know the latest version of parse-server requires a minimum node version 6.11.4. Can you have a look into travis? |
Sure thing @dplewis , I'll see what's going on here... |
Took a look locally, seems to be just an outdated version of parse-server in cache. Dumped it and rerunning now. I did see one failure which looks to be consistent and is beyond this PR, probably due to a change in the server. We'll see if it reproduces when these run through. |
Are you talking about the |
Nope, schema tests look good actually. This is what I saw locally.
Curious if it's just a local issue or if it will repeat up here. If so I'll need to take a further look. |
@montymxb I got that as well |
Looks like there's still further issues starting up the test server. I'll have to look at this tomorrow when I have some time. |
@dplewis master is good now, you can merge against it when you have a moment. |
Codecov Report
@@ Coverage Diff @@
## master #357 +/- ##
==========================================
+ Coverage 99.01% 99.02% +<.01%
==========================================
Files 38 38
Lines 3562 3579 +17
==========================================
+ Hits 3527 3544 +17
Misses 35 35
Continue to review full report at Codecov.
|
@montymxb thanks for fixing the tests |
src/Parse/ParseSchema.php
Outdated
/** | ||
* Adding an Index to Create / Update a Schema. | ||
* | ||
* @param string $indexName Name of the index will created on Parse |
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.
Bit of a typo
Name of the index that will be created on Parse
src/Parse/ParseSchema.php
Outdated
* | ||
* @return ParseSchema indexes return self to create index on Parse | ||
*/ | ||
public function addIndex($indexName = null, $index = 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.
Not sure why default values of null
are needed for both of the args. I think those defaults should be removed considering that a null value would cause this to throw an exception.
src/Parse/ParseSchema.php
Outdated
@@ -614,6 +654,18 @@ public function deleteField($fieldName = null) | |||
]; | |||
} | |||
|
|||
/** | |||
* Deleting a Index to Update on a Schema. |
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.
Deleting an Index
src/Parse/ParseSchema.php
Outdated
/** | ||
* Deleting a Index to Update on a Schema. | ||
* | ||
* @param string $indexName Name of the index will be deleted |
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.
that will be
tests/Parse/ParseSchemaTest.php
Outdated
|
||
$schema->addString('name'); | ||
$schema->update(); | ||
$schema->update(); |
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.
Double update?
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.
There was a bug where calling multiple updates would create multiple fields / indexes. I don't think this was intended functionality. Thus the testUpdateMultipleSchemaStream
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.
Ahh, this is fine then.
tests/Parse/ParseSchemaTest.php
Outdated
$schema = new ParseSchema(self::$badClassName); | ||
$schema->delete(); | ||
} | ||
|
||
public function testCreateIndexSchemaStream() |
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 would consolidate these pair tests into singular tests. You don't need to manually test each as part of the CI selectively runs the entire test suite against the stream client in addition to the curl client. The other reason being if we ever add additional clients in the future we would have to add additional tests if we did it this way, versus just adding another CI run selectively using the alternate client instead.
There are some tests in here that still do this and it was probably me who added them. Those were early tests before I had setup the independent curl/stream CI runs. Honestly they can be selectively phased out at now. But to sum it up we shouldn't add additional stream differing tests (unless there's an extenuating circumstance) as it's redundant now.
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 to detail where it is you can see the stream client testing in the matrix for 5.4 and HHVM and later you can see how it is actually factored into the tests here.
tests/Parse/ParseSchemaTest.php
Outdated
|
||
public function testDeleteIndexSchema() | ||
{ | ||
ParseClient::setHttpClient(new ParseStreamHttpClient()); |
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.
Since this one is just on it's own you can just clear out the manual client.
#### Index | ||
Indexes support efficient execution of queries from the database. MasterKey is required. | ||
```php | ||
// To add an index, the field must exist before you create an index |
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.
Could you add a few lines showing how to check existing indexes?
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.
Alright tests are finally good now. I gave this a thorough review, typos, suggestions, etc. If you can make those changes I'll give this another go and we should be pretty close to good here.
@@ -411,7 +429,7 @@ public function testBadSchemaGet() | |||
*/ | |||
public function testBadSchemaSave() | |||
{ | |||
$this->setExpectedException('\Parse\ParseException'); | |||
$this->setExpectedException('\Exception'); |
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.
One last thing. Is there a particular reason you changed the expected exception here?
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.
https://github.com/dplewis/parse-php-sdk/blob/schema-index/src/Parse/ParseSchema.php#L277
It throws exception instead of parse exception. The test were failing locally for some reason.
On a side note testBadSchemaDelete doesn't pass locally for me. If I remove the spaces from $badClassName = "<Bad~ Class~ Name>
it passes. Weird.
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.
Ahh that's something I missed. That change is good then. And quick question, are you running these tests on a windows machine by chance?
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.
MacOS 10.12.6 Sierra
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.
Hmm, good on mine and we're on the same setup. There's certainly a reason for it but I wonder what 🤔 . Anyways this is all good then.
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.
Thanks for waiting. Now onto 1.4.0 👍
@@ -427,7 +445,7 @@ public function testBadSchemaSave() | |||
*/ | |||
public function testBadSchemaUpdate() | |||
{ | |||
$this->setExpectedException('\Parse\ParseException'); | |||
$this->setExpectedException('\Exception'); |
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 question for this here too.
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 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.
Everything looks good. Just need to hear about a change on a pair of expected exceptions and we're good.
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.
approved
Sweet we're ready for 1.4.0. I'll craft a release later tonight. |
Pending: parse-community/parse-server#4240