Skip to content

Commit

Permalink
fix: fix alter property limit in edit page (#514)
Browse files Browse the repository at this point in the history
* fix: fix alter property limit in edit page

* mod: code review
  • Loading branch information
hetao92 committed Mar 29, 2023
1 parent 7fd290a commit 2f41997
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import { AlterType, IProperty } from '@app/interfaces/schema';
import { useI18n } from '@vesoft-inc/i18n';
import { nameRulesFn, numberRulesFn, stringByteRulesFn } from '@app/config/rules';
import { DATA_TYPE, EXPLAIN_DATA_TYPE } from '@app/utils/constant';
import { DataTypeTransformMap, DATA_TYPE, EXPLAIN_DATA_TYPE } from '@app/utils/constant';

import styles from './index.module.less';
const Option = Select.Option;
Expand Down Expand Up @@ -102,8 +102,11 @@ export const EditRow = (props: IEditProps) => {
message: intl.get('formRules.dataTypeRequired'),
},
]}>
<Select showSearch={true} onChange={onUpdateType} dropdownMatchSelectWidth={false}>
<Select disabled={!(type in DataTypeTransformMap)} showSearch={true} onChange={onUpdateType} dropdownMatchSelectWidth={false}>
{DATA_TYPE.map(item => {
if(!DataTypeTransformMap[type]?.includes(item.value) || item.value !== type) {
return null;
}
return (
<Option value={item.value} key={item.value}>
{item.label}
Expand Down
8 changes: 8 additions & 0 deletions app/utils/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ export const ENUM_OF_COMPARE = {
],
};

export const DataTypeTransformMap = {
int8: ['int16', 'int32', 'int'],
int16: ['int32', 'int'],
int32: ['int'],
fixed_string: ['string'],
float: ['double'],
} as const;

export const DATA_TYPE = [
{
value: 'int',
Expand Down
6 changes: 3 additions & 3 deletions server/api/studio/pkg/client/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,9 @@ func parseExecuteData(response SingleResponse) (ParsedResult, error) {
return result, nil
}

if !res.IsSucceed() {
return result, errors.New(res.GetErrorMsg())
}
if res.IsSetPlanDesc() {
resp := response.Result
if response.Result == nil {
Expand Down Expand Up @@ -510,9 +513,6 @@ func parseExecuteData(response SingleResponse) (ParsedResult, error) {
return result, nil
}
}
if !res.IsSucceed() {
return result, errors.New(res.GetErrorMsg())
}
if !res.IsEmpty() {
rows := res.GetRows()
rowSize := len(rows)
Expand Down

0 comments on commit 2f41997

Please sign in to comment.