Browse Source

fix: use pluralised name of ref table as column name

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5848/head
Pranav C 1 year ago
parent
commit
1e79467ac5
  1. 1
      packages/nc-gui/components/dlg/AirtableImport.vue
  2. 2
      packages/nocodb/src/helpers/columnHelpers.ts
  3. 6
      packages/nocodb/src/helpers/populateMeta.ts
  4. 4
      packages/nocodb/src/services/columns.service.ts
  5. 8
      packages/nocodb/src/services/meta-diffs.service.ts

1
packages/nc-gui/components/dlg/AirtableImport.vue

@ -1,3 +1,4 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Card as AntCard } from 'ant-design-vue' import type { Card as AntCard } from 'ant-design-vue'
import { import {

2
packages/nocodb/src/helpers/columnHelpers.ts

@ -65,7 +65,7 @@ export async function createHmAndBtColumn(
{ {
const title = getUniqueColumnAliasName( const title = getUniqueColumnAliasName(
await parent.getColumns(), await parent.getColumns(),
(type === 'hm' && alias) || `${child.title}`, (type === 'hm' && alias) || pluralize(child.title),
); );
const meta = { const meta = {
plural: columnMeta?.plural || pluralize(child.title), plural: columnMeta?.plural || pluralize(child.title),

6
packages/nocodb/src/helpers/populateMeta.ts

@ -114,7 +114,7 @@ export async function extractAndGenerateManyToManyRelations(
await Column.insert<LinkToAnotherRecordColumn>({ await Column.insert<LinkToAnotherRecordColumn>({
title: getUniqueColumnAliasName( title: getUniqueColumnAliasName(
modelA.columns, modelA.columns,
`${modelB.title} List`, pluralize(modelB.title),
), ),
fk_model_id: modelA.id, fk_model_id: modelA.id,
fk_related_model_id: modelB.id, fk_related_model_id: modelB.id,
@ -136,7 +136,7 @@ export async function extractAndGenerateManyToManyRelations(
await Column.insert<LinkToAnotherRecordColumn>({ await Column.insert<LinkToAnotherRecordColumn>({
title: getUniqueColumnAliasName( title: getUniqueColumnAliasName(
modelB.columns, modelB.columns,
`${modelA.title} List`, pluralize(modelA.title),
), ),
fk_model_id: modelB.id, fk_model_id: modelB.id,
fk_related_model_id: modelA.id, fk_related_model_id: modelA.id,
@ -268,7 +268,7 @@ export async function populateMeta(base: Base, project: Project): Promise<any> {
uidt: UITypes.Links, uidt: UITypes.Links,
type: 'hm', type: 'hm',
hm, hm,
title: `${hm.title} List`, title: pluralize(hm.title),
meta: { meta: {
plural: pluralize(hm.title), plural: pluralize(hm.title),
singular: singularize(hm.title), singular: singularize(hm.title),

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

@ -1780,7 +1780,7 @@ export class ColumnsService {
await Column.insert({ await Column.insert({
title: getUniqueColumnAliasName( title: getUniqueColumnAliasName(
await child.getColumns(), await child.getColumns(),
`${parent.title} List`, pluralize(parent.title),
), ),
uidt: isLinks ? UITypes.Links : UITypes.LinkToAnotherRecord, uidt: isLinks ? UITypes.Links : UITypes.LinkToAnotherRecord,
type: 'mm', type: 'mm',
@ -1807,7 +1807,7 @@ export class ColumnsService {
await Column.insert({ await Column.insert({
title: getUniqueColumnAliasName( title: getUniqueColumnAliasName(
await parent.getColumns(), await parent.getColumns(),
param.column.title ?? `${child.title} List`, param.column.title ?? pluralize(child.title),
), ),
uidt: isLinks ? UITypes.Links : UITypes.LinkToAnotherRecord, uidt: isLinks ? UITypes.Links : UITypes.LinkToAnotherRecord,

8
packages/nocodb/src/services/meta-diffs.service.ts

@ -746,7 +746,7 @@ export class MetaDiffsService {
} else if (change.relationType === RelationTypes.HAS_MANY) { } else if (change.relationType === RelationTypes.HAS_MANY) {
const title = getUniqueColumnAliasName( const title = getUniqueColumnAliasName(
childModel.columns, childModel.columns,
`${childModel.title || childModel.table_name} List`, pluralize(childModel.title || childModel.table_name),
); );
await Column.insert<LinkToAnotherRecordColumn>({ await Column.insert<LinkToAnotherRecordColumn>({
uidt: UITypes.Links, uidt: UITypes.Links,
@ -945,7 +945,7 @@ export class MetaDiffsService {
} else if (change.relationType === RelationTypes.HAS_MANY) { } else if (change.relationType === RelationTypes.HAS_MANY) {
const title = getUniqueColumnAliasName( const title = getUniqueColumnAliasName(
childModel.columns, childModel.columns,
`${childModel.title || childModel.table_name} List`, pluralize(childModel.title || childModel.table_name),
); );
await Column.insert<LinkToAnotherRecordColumn>({ await Column.insert<LinkToAnotherRecordColumn>({
uidt: UITypes.Links, uidt: UITypes.Links,
@ -1046,7 +1046,7 @@ export class MetaDiffsService {
await Column.insert<LinkToAnotherRecordColumn>({ await Column.insert<LinkToAnotherRecordColumn>({
title: getUniqueColumnAliasName( title: getUniqueColumnAliasName(
modelA.columns, modelA.columns,
`${modelB.title} List`, pluralize(modelB.title),
), ),
fk_model_id: modelA.id, fk_model_id: modelA.id,
fk_related_model_id: modelB.id, fk_related_model_id: modelB.id,
@ -1070,7 +1070,7 @@ export class MetaDiffsService {
await Column.insert<LinkToAnotherRecordColumn>({ await Column.insert<LinkToAnotherRecordColumn>({
title: getUniqueColumnAliasName( title: getUniqueColumnAliasName(
modelB.columns, modelB.columns,
`${modelA.title} List`, pluralize(modelA.title),
), ),
fk_model_id: modelB.id, fk_model_id: modelB.id,
fk_related_model_id: modelA.id, fk_related_model_id: modelA.id,

Loading…
Cancel
Save