@@ -132,17 +132,16 @@ function validateCLP(perms) {
132
132
} ) ;
133
133
} ) ;
134
134
}
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
139
135
var joinClassRegex = / ^ _ J o i n : [ A - Z a - z 0 - 9 _ ] + : [ A - Z a - z 0 - 9 _ ] + / ;
140
136
var classAndFieldRegex = / ^ [ A - Z a - z ] [ A - Z a - z 0 - 9 _ ] * $ / ;
141
137
function 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
144
143
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
146
145
fieldNameIsValid ( className )
147
146
) ;
148
147
}
@@ -272,14 +271,13 @@ class Schema {
272
271
}
273
272
274
273
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
+ } ) ;
283
281
}
284
282
285
283
updateClass ( className , submittedFields , classLevelPermissions , database ) {
0 commit comments