Skip to content

Commit

Permalink
Revert "Add Indexes to Schema API (#4240)"
Browse files Browse the repository at this point in the history
This reverts commit d5c4324.
  • Loading branch information
flovilmart authored Nov 25, 2017
1 parent d5c4324 commit ac120a8
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 958 deletions.
8 changes: 1 addition & 7 deletions spec/MongoSchemaCollectionAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ describe('MongoSchemaCollection', () => {
"create":{"*":true},
"delete":{"*":true},
"addField":{"*":true},
},
"indexes": {
"name1":{"deviceToken":1}
}
},
"installationId":"string",
Expand Down Expand Up @@ -69,10 +66,7 @@ describe('MongoSchemaCollection', () => {
update: { '*': true },
delete: { '*': true },
addField: { '*': true },
},
indexes: {
name1: {deviceToken: 1}
},
}
});
done();
});
Expand Down
124 changes: 34 additions & 90 deletions spec/ParseQuery.FullTextSearch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ const fullTextHelper = () => {
const request = {
method: "POST",
body: {
subject: subjects[i],
comment: subjects[i],
subject: subjects[i]
},
path: "/1/classes/TestObject"
};
Expand Down Expand Up @@ -281,83 +280,42 @@ describe('Parse.Query Full Text Search testing', () => {
});

describe_only_db('mongo')('Parse.Query Full Text Search testing', () => {
it('fullTextSearch: does not create text index if compound index exist', (done) => {
fullTextHelper().then(() => {
return databaseAdapter.dropAllIndexes('TestObject');
}).then(() => {
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(1);
return databaseAdapter.createIndex('TestObject', {subject: 'text', comment: 'text'});
it('fullTextSearch: $search, only one text index', (done) => {
return reconfigureServer({
appId: 'test',
restAPIKey: 'test',
publicServerURL: 'http://localhost:8378/1',
databaseAdapter: new MongoStorageAdapter({ uri: mongoURI })
}).then(() => {
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(2);
const where = {
subject: {
$text: {
$search: {
$term: 'coffee'
}
}
}
};
return rp.post({
url: 'http://localhost:8378/1/classes/TestObject',
json: { where, '_method': 'GET' },
url: 'http://localhost:8378/1/batch',
body: {
requests: [
{
method: "POST",
body: {
subject: "coffee is java"
},
path: "/1/classes/TestObject"
},
{
method: "POST",
body: {
subject: "java is coffee"
},
path: "/1/classes/TestObject"
}
]
},
json: true,
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'test'
}
});
}).then((resp) => {
expect(resp.results.length).toEqual(3);
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(2);
rp.get({
url: 'http://localhost:8378/1/schemas/TestObject',
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-Master-Key': 'test',
},
json: true,
}, (error, response, body) => {
expect(body.indexes._id_).toBeDefined();
expect(body.indexes._id_._id).toEqual(1);
expect(body.indexes.subject_text_comment_text).toBeDefined();
expect(body.indexes.subject_text_comment_text.subject).toEqual('text');
expect(body.indexes.subject_text_comment_text.comment).toEqual('text');
done();
});
}).catch(done.fail);
});

it('fullTextSearch: does not create text index if schema compound index exist', (done) => {
fullTextHelper().then(() => {
return databaseAdapter.dropAllIndexes('TestObject');
}).then(() => {
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(1);
return rp.put({
url: 'http://localhost:8378/1/schemas/TestObject',
json: true,
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'test',
'X-Parse-Master-Key': 'test',
},
body: {
indexes: {
text_test: { subject: 'text', comment: 'text'},
},
},
});
return databaseAdapter.createIndex('TestObject', {random: 'text'});
}).then(() => {
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(2);
const where = {
subject: {
$text: {
Expand All @@ -376,26 +334,12 @@ describe_only_db('mongo')('Parse.Query Full Text Search testing', () => {
}
});
}).then((resp) => {
expect(resp.results.length).toEqual(3);
return databaseAdapter.getIndexes('TestObject');
}).then((indexes) => {
expect(indexes.length).toEqual(2);
rp.get({
url: 'http://localhost:8378/1/schemas/TestObject',
headers: {
'X-Parse-Application-Id': 'test',
'X-Parse-Master-Key': 'test',
},
json: true,
}, (error, response, body) => {
expect(body.indexes._id_).toBeDefined();
expect(body.indexes._id_._id).toEqual(1);
expect(body.indexes.text_test).toBeDefined();
expect(body.indexes.text_test.subject).toEqual('text');
expect(body.indexes.text_test.comment).toEqual('text');
done();
});
}).catch(done.fail);
fail(`Should not be more than one text index: ${JSON.stringify(resp)}`);
done();
}).catch((err) => {
expect(err.error.code).toEqual(Parse.Error.INTERNAL_SERVER_ERROR);
done();
});
});

it('fullTextSearch: $diacriticSensitive - false', (done) => {
Expand Down
5 changes: 1 addition & 4 deletions spec/Schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ describe('SchemaController', () => {
fooSixteen: {type: 'String'},
fooEighteen: {type: 'String'},
fooNineteen: {type: 'String'},
}, levelPermissions, {}, config.database))
}, levelPermissions, config.database))
.then(actualSchema => {
const expectedSchema = {
className: 'NewClass',
Expand Down Expand Up @@ -304,9 +304,6 @@ describe('SchemaController', () => {
fooNineteen: {type: 'String'},
},
classLevelPermissions: { ...levelPermissions },
indexes: {
_id_: { _id: 1 }
}
};

expect(dd(actualSchema, expectedSchema)).toEqual(undefined);
Expand Down
Loading

0 comments on commit ac120a8

Please sign in to comment.