diff --git a/packages/nc-gui/components/smartsheet-column/AdvancedOptions.vue b/packages/nc-gui/components/smartsheet-column/AdvancedOptions.vue index 2df03d1e7d..97d68eb9ca 100644 --- a/packages/nc-gui/components/smartsheet-column/AdvancedOptions.vue +++ b/packages/nc-gui/components/smartsheet-column/AdvancedOptions.vue @@ -96,7 +96,7 @@ onBeforeMount(() => { /> - + diff --git a/packages/nc-gui/composables/useColumnCreateStore.ts b/packages/nc-gui/composables/useColumnCreateStore.ts index ef6995df82..1d01368c63 100644 --- a/packages/nc-gui/composables/useColumnCreateStore.ts +++ b/packages/nc-gui/composables/useColumnCreateStore.ts @@ -109,20 +109,22 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState } } - if (column.value?.uidt === UITypes.Currency) { + // keep length and scale for same datatype + if (column.value && formState.value.uidt === column.value?.uidt) { formState.value.dtxp = column.value.dtxp formState.value.dtxs = column.value.dtxs } else { - formState.value.dtxp = 19 - formState.value.dtxs = 2 + // default length and scale for currency + if (formState.value?.uidt === UITypes.Currency) { + formState.value.dtxp = 19 + formState.value.dtxs = 2 + } } formState.value.altered = formState.value.altered || 2 } const onDataTypeChange = () => { - const { isCurrency } = useColumn(ref(formState.value as ColumnType)) - formState.value.rqd = false if (formState.value.uidt !== UITypes.ID) { formState.value.primaryKey = false @@ -135,16 +137,19 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState formState.value.dtx = 'specificType' + // use enum response as dtxp for select columns const selectTypes = [UITypes.MultiSelect, UITypes.SingleSelect] if (column.value && selectTypes.includes(formState.value.uidt) && selectTypes.includes(column.value.uidt as UITypes)) { formState.value.dtxp = column.value.dtxp } - if (isCurrency.value) { - if (column.value?.uidt === UITypes.Currency) { - formState.value.dtxp = column.value.dtxp - formState.value.dtxs = column.value.dtxs - } else { + // keep length and scale for same datatype + if (column.value && formState.value.uidt === column.value?.uidt) { + formState.value.dtxp = column.value.dtxp + formState.value.dtxs = column.value.dtxs + } else { + // default length and scale for currency + if (formState.value?.uidt === UITypes.Currency) { formState.value.dtxp = 19 formState.value.dtxs = 2 } diff --git a/packages/nocodb/src/lib/meta/api/columnApis.ts b/packages/nocodb/src/lib/meta/api/columnApis.ts index cd2cefc078..ce691e71c1 100644 --- a/packages/nocodb/src/lib/meta/api/columnApis.ts +++ b/packages/nocodb/src/lib/meta/api/columnApis.ts @@ -514,6 +514,9 @@ export async function columnAdd(req: Request, res: Response) { const dbDriver = NcConnectionMgrv2.get(base); const driverType = dbDriver.clientType(); const optionTitles = colBody.colOptions.options.map(el => el.title.replace(/'/g, "''")); + + // this is not used for select columns and cause issue for MySQL + colBody.dtxs = ''; // Handle default values if (colBody.cdf) { if (colBody.uidt === UITypes.SingleSelect) {