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

Add Indexes via Schema #357

Merged
merged 6 commits into from
Dec 2, 2017
Merged

Conversation

dplewis
Copy link
Member

@dplewis dplewis commented Oct 8, 2017

@montymxb
Copy link
Contributor

Cool! Same deal here as with the aggregate queries. Once the server side functionality is in I'll go over this.

@montymxb montymxb added this to the 1.4.0 milestone Nov 13, 2017
@dplewis
Copy link
Member Author

dplewis commented Nov 26, 2017

@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?

@montymxb
Copy link
Contributor

Sure thing @dplewis , I'll see what's going on here...

@montymxb
Copy link
Contributor

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.

@dplewis
Copy link
Member Author

dplewis commented Nov 26, 2017

Are you talking about the testBadSchemaDelete or testCheckBadServer tests? I got those failing when running locally.

@montymxb
Copy link
Contributor

Nope, schema tests look good actually. This is what I saw locally.

1) Parse\Test\ParseFileTest::testParseFileTypes
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'application/octet-stream'
+'null'

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.

@dplewis
Copy link
Member Author

dplewis commented Nov 26, 2017

@montymxb I got that as well

@montymxb
Copy link
Contributor

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.

@montymxb
Copy link
Contributor

@dplewis master is good now, you can merge against it when you have a moment.

@codecov
Copy link

codecov bot commented Nov 29, 2017

Codecov Report

Merging #357 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #357      +/-   ##
==========================================
+ Coverage   99.01%   99.02%   +<.01%     
==========================================
  Files          38       38              
  Lines        3562     3579      +17     
==========================================
+ Hits         3527     3544      +17     
  Misses         35       35
Impacted Files Coverage Δ
src/Parse/ParseSchema.php 97.3% <100%> (+0.22%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8fdecc...c3531e7. Read the comment docs.

@dplewis
Copy link
Member Author

dplewis commented Nov 29, 2017

@montymxb thanks for fixing the tests

/**
* Adding an Index to Create / Update a Schema.
*
* @param string $indexName Name of the index will created on Parse
Copy link
Contributor

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

*
* @return ParseSchema indexes return self to create index on Parse
*/
public function addIndex($indexName = null, $index = null)
Copy link
Contributor

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.

@@ -614,6 +654,18 @@ public function deleteField($fieldName = null)
];
}

/**
* Deleting a Index to Update on a Schema.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting an Index

/**
* Deleting a Index to Update on a Schema.
*
* @param string $indexName Name of the index will be deleted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that will be


$schema->addString('name');
$schema->update();
$schema->update();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double update?

Copy link
Member Author

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

Copy link
Contributor

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.

$schema = new ParseSchema(self::$badClassName);
$schema->delete();
}

public function testCreateIndexSchemaStream()
Copy link
Contributor

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.

Copy link
Contributor

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.


public function testDeleteIndexSchema()
{
ParseClient::setHttpClient(new ParseStreamHttpClient());
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor

@montymxb montymxb left a 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');
Copy link
Contributor

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?

Copy link
Member Author

@dplewis dplewis Dec 2, 2017

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.

Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

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.

Copy link
Member Author

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');
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same above

Copy link
Contributor

@montymxb montymxb left a 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.

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:octocat: approved

@montymxb montymxb merged commit e0e2dc8 into parse-community:master Dec 2, 2017
@montymxb
Copy link
Contributor

montymxb commented Dec 2, 2017

Sweet we're ready for 1.4.0. I'll craft a release later tonight.

@dplewis dplewis deleted the schema-index branch May 22, 2018 20:35
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