@@ -132,17 +132,16 @@ function validateCLP(perms) {
132132 } ) ;
133133 } ) ;
134134}
135- // Valid classes must:
136- // Be one of _User, _Installation, _Role, _Session OR
137- // Be a join table OR
138- // Include only alpha-numeric and underscores, and not start with an underscore or number
139135var joinClassRegex = / ^ _ J o i n : [ A - Z a - z 0 - 9 _ ] + : [ A - Z a - z 0 - 9 _ ] + / ;
140136var classAndFieldRegex = / ^ [ A - Z a - z ] [ A - Z a - z 0 - 9 _ ] * $ / ;
141137function classNameIsValid ( className ) {
142- return ( systemClasses . indexOf ( className ) > - 1 ||
143- className === '_SCHEMA' || //TODO: remove this, as _SCHEMA is not a valid class name for storing Parse Objects.
138+ // Valid classes must:
139+ return (
140+ // Be one of _User, _Installation, _Role, _Session OR
141+ systemClasses . indexOf ( className ) > - 1 ||
142+ // Be a join table OR
144143 joinClassRegex . test ( className ) ||
145- //Class names have the same constraints as field names, but also allow the previous additional names.
144+ // Include only alpha-numeric and underscores, and not start with an underscore or number
146145 fieldNameIsValid ( className )
147146 ) ;
148147}
@@ -272,14 +271,13 @@ class Schema {
272271 }
273272
274273 return this . _collection . addSchema ( className , mongoObject . result )
275- //TODO: Move this logic into the database adapter
276- . then ( result => MongoSchemaCollection . _TESTmongoSchemaToParseSchema ( result . ops [ 0 ] ) )
277- . catch ( error => {
278- if ( error . code === 11000 ) { //Mongo's duplicate key error
279- throw new Parse . Error ( Parse . Error . INVALID_CLASS_NAME , `Class ${ className } already exists.` ) ;
280- }
281- return Promise . reject ( error ) ;
282- } ) ;
274+ . catch ( error => {
275+ if ( error === undefined ) {
276+ throw new Parse . Error ( Parse . Error . INVALID_CLASS_NAME , `Class ${ className } already exists.` ) ;
277+ } else {
278+ throw new Parse . Error ( Parse . Error . INTERNAL_SERVER_ERROR , 'Database adapter error.' ) ;
279+ }
280+ } ) ;
283281 }
284282
285283 updateClass ( className , submittedFields , classLevelPermissions , database ) {
0 commit comments