Browse Source

Merge pull request #6898 from nocodb/nc-fix/ignore-column-camelization-when-inflection-set-none

Nc fix/ignore column camelization when inflection set none
pull/6904/head
Raju Udava 1 year ago committed by GitHub
parent
commit
48bff4e7e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue
  2. 8
      packages/nc-gui/components/dashboard/settings/data-sources/EditBase.vue
  3. 30
      packages/nc-gui/composables/useTableNew.ts

9
packages/nc-gui/components/dashboard/settings/data-sources/CreateBase.vue

@ -66,8 +66,8 @@ const formState = ref<ProjectCreateForm>({
title: '',
dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) },
inflection: {
inflectionColumn: 'camelize',
inflectionTable: 'camelize',
inflectionColumn: 'none',
inflectionTable: 'none',
},
sslUse: SSLUsage.No,
extraParameters: [],
@ -77,8 +77,8 @@ const customFormState = ref<ProjectCreateForm>({
title: '',
dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) },
inflection: {
inflectionColumn: 'camelize',
inflectionTable: 'camelize',
inflectionColumn: 'none',
inflectionTable: 'none',
},
sslUse: SSLUsage.No,
extraParameters: [],
@ -614,7 +614,6 @@ const toggleModal = (val: boolean) => {
</a-form-item>
<a-divider />
<a-form-item :label="$t('labels.inflection.tableName')">
<a-select
v-model:value="formState.inflection.inflectionTable"

8
packages/nc-gui/components/dashboard/settings/data-sources/EditBase.vue

@ -61,8 +61,8 @@ const formState = ref<ProjectCreateForm>({
title: '',
dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) },
inflection: {
inflectionColumn: 'camelize',
inflectionTable: 'camelize',
inflectionColumn: 'none',
inflectionTable: 'none',
},
sslUse: SSLUsage.No,
extraParameters: [],
@ -72,8 +72,8 @@ const customFormState = ref<ProjectCreateForm>({
title: '',
dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) },
inflection: {
inflectionColumn: 'camelize',
inflectionTable: 'camelize',
inflectionColumn: 'none',
inflectionTable: 'none',
},
sslUse: SSLUsage.No,
extraParameters: [],

30
packages/nc-gui/composables/useTableNew.ts

@ -113,17 +113,29 @@ export function useTableNew(param: { onTableCreate?: (tableMeta: TableType) => v
}
const sqlUi = await basesStore.getSqlUi(baseId, sourceId)
const source = bases.value.get(baseId)?.sources?.find((s) => s.id === sourceId)
if (!sqlUi) return
const columns = sqlUi?.getNewTableColumns().filter((col: ColumnType) => {
if (col.column_name === 'id' && table.columns.includes('id_ag')) {
Object.assign(col, sqlUi?.getDataTypeForUiType({ uidt: UITypes.ID }, 'AG'))
col.dtxp = sqlUi?.getDefaultLengthForDatatype(col.dt)
col.dtxs = sqlUi?.getDefaultScaleForDatatype(col.dt)
return true
}
return table.columns.includes(col.column_name!)
})
const columns = sqlUi
?.getNewTableColumns()
.filter((col: ColumnType) => {
if (col.column_name === 'id' && table.columns.includes('id_ag')) {
Object.assign(col, sqlUi?.getDataTypeForUiType({ uidt: UITypes.ID }, 'AG'))
col.dtxp = sqlUi?.getDefaultLengthForDatatype(col.dt)
col.dtxs = sqlUi?.getDefaultScaleForDatatype(col.dt)
return true
}
return table.columns.includes(col.column_name!)
})
.map((column) => {
if (!source) return column
if (source.inflection_column !== 'camelize') {
column.title = column.column_name
}
return column
})
try {
const tableMeta = await $api.source.tableCreate(baseId, sourceId!, {

Loading…
Cancel
Save