Browse Source

refactor: suggested review changes

pull/9660/head
Pranav C 1 month ago
parent
commit
6b77f5c2df
  1. 2
      packages/nc-gui/components/cell/Rating.vue
  2. 5
      packages/nocodb/src/services/columns.service.ts
  3. 19
      packages/nocodb/src/services/tables.service.ts
  4. 1
      packages/nocodb/tests/unit/rest/tests/table.test.ts

2
packages/nc-gui/components/cell/Rating.vue

@ -1,6 +1,4 @@
<script setup lang="ts">
import { extractRatingIcon } from '../../utils/columnUtils'
interface Props {
modelValue?: number | null | undefined
}

5
packages/nocodb/src/services/columns.service.ts

@ -1627,6 +1627,11 @@ export class ColumnsService {
reuse?: ReusableParams;
},
) {
// if column_name is defined and title is not defined, set title to column_name
if (param.column.column_name && !param.column.title) {
param.column.title = param.column.column_name;
}
validatePayload('swagger.json#/components/schemas/ColumnReq', param.column);
const reuse = param.reuse || {};

19
packages/nocodb/src/services/tables.service.ts

@ -466,6 +466,20 @@ export class TablesService {
req?: any;
},
) {
// before validating add title for columns if only column name is present
if (param.table.columns) {
param.table.columns.forEach((c) => {
if (!c.title && c.column_name) {
c.title = c.column_name;
}
});
}
// before validating add title for table if only table name is present
if (!param.table.title && param.table.table_name) {
param.table.title = param.table.table_name
}
validatePayload('swagger.json#/components/schemas/TableReq', param.table);
const tableCreatePayLoad: Omit<TableReqType, 'columns'> & {
@ -651,6 +665,11 @@ export class TablesService {
) {
const mxColumnLength = Column.getMaxColumnNameLength(sqlClientType);
// set column name using title if not present
if (!column.column_name && column.title) {
column.column_name = column.title;
}
// - 5 is a buffer for suffix
column.column_name = sanitizeColumnName(
column.column_name.slice(0, mxColumnLength - 5),

1
packages/nocodb/tests/unit/rest/tests/table.test.ts

@ -53,7 +53,6 @@ function tableStaticTests() {
.post(`/api/v1/db/meta/projects/${base.id}/tables`)
.set('xc-auth', context.token)
.send({
table_name: 'new_table_name',
title: undefined,
columns: defaultColumns(context),
})

Loading…
Cancel
Save