/** * Attempt to get the constraint by parsing the SQL statement * @param constraintSql constraint SQL statement * @param table true to search for a table constraint, false to search for a column constraint * @return constraint or null */ static getConstraint(constraintSql: string, table: boolean): Constraint { let constraint = null; const nameAndDefinition = ConstraintParser.getNameAndDefinition(constraintSql); const definition = nameAndDefinition[1]; if (definition !== null && definition !== undefined) { const prefix = definition.split(/\s+/)[0]; let type = null; if (table) { type = ConstraintType.getTableType(prefix); } else { type = ConstraintType.getColumnType(prefix); } if (type !== null && type !== undefined) { constraint = new RawConstraint(type, nameAndDefinition[0], constraintSql.trim()); } } return constraint; }
var nameAndDefinition = ConstraintParser.getNameAndDefinition(constraintSql); var definition = nameAndDefinition[1]; if (definition !== null && definition !== undefined) {