Repository: hasura/graphql-engine
File: console/src/components/Services/Data/TableModify/ColumnEditorList.js (JavaScript)

Code before:
      pkConstraint: columnPKConstraints[colName],
      isUnique: isColumnUnique(tableSchema, colName),
      // uniqueConstraint: columnUniqueConstraints[colName],
      default: col.column_default || '',
      comment: col.comment || '',
      customFieldName: customColumnNames[colName] || '',
      isOnlyPrimaryKey: columnPKConstraints[colName] && pkLength === 1,
    };

    const onSubmit = toggleEditor => {
      dispatch(saveColumnChangesSql(colName, col, toggleEditor));
    };

    const onDelete = () => {
      let confirmMessage = `This will permanently delete the column "${colName}" from this table`;
      if (columnProperties.pkConstraint) {
        confirmMessage = DELETE_PK_WARNING;
      }

      const isOk = getConfirmation(confirmMessage, true, colName);
      if (isOk) {
        const pk = [];
        let flag = true;
        for (const [_, value1] of tableSchema.primary_key.columns.entries()) {
          for (const [index2, value2] of tableSchema.columns.entries()) {
            if (value2.column_name.localeCompare(colName) == 0) {
              flag = false;
            } else {
              if (
                flag == true &&
                value1.localeCompare(value2.column_name) == 0
              ) {
                pk.push(index2);
              } else if (value1.localeCompare(value2.column_name) == 0) {
                pk.push(index2 - 1);
              }
            }
          }
          flag = true;
        }
        const pks = [];
        for (const [_, value1] of pk.sort().entries()) {
          pks.push(value1.toString());
        }
        pks.push('');
        dispatch(setPrimaryKeys(pks));
        dispatch(deleteColumnSql(col, tableSchema));
      }
    };

    const gqlCompatibilityWarning = () => {

Review comment (suggestion):
2 Notes here:
 - Preferrable to use `===` over `==`
 - the whole conditional can be replaced with `if (!value2.column_name.localeCompare(colName))`, since `0` is a `falsy` value. (Read more here: https://developer.mozilla.org/en-US/docs/Glossary/Falsy)

Code after:
      // uniqueConstraint: columnUniqueConstraints[colName],
      default: col.column_default || '',
      comment: col.comment || '',
      customFieldName: customColumnNames[colName] || '',
      isOnlyPrimaryKey: columnPKConstraints[colName] && pkLength === 1,
    };

    const onSubmit = toggleEditor => {
      dispatch(saveColumnChangesSql(colName, col, toggleEditor));
    };

    const onDelete = () => {
      let confirmMessage = `This will permanently delete the column "${colName}" from this table`;
      if (columnProperties.pkConstraint) {
        confirmMessage = DELETE_PK_WARNING;
      }

      const isOk = getConfirmation(confirmMessage, true, colName);
      if (isOk) {
        dispatch(deleteColumnSql(col, tableSchema));
      }
    };
    const gqlCompatibilityWarning = () => {
      return (
        <GqlCompatibilityWarning
          identifier={colName}
          className={styles.add_mar_left_small}
        />
      );
    };

    const keyProperties = () => {
      const propertiesDisplay = [];

      const propertiesList = [];
      propertiesList.push(columnProperties.display_type_name);

      if (columnProperties.pkConstraint) {
        propertiesList.push('primary key');
      }

      if (columnProperties.isUnique || columnProperties.isOnlyPrimaryKey) {
        propertiesList.push('unique');
      }

      if (columnProperties.isIdentity) {
        propertiesList.push('identity');
      }

      if (columnProperties.isNullable) {
        propertiesList.push('nullable');