nocodb icon indicating copy to clipboard operation
nocodb copied to clipboard

🐛 Bug: Link record between Atbl Imported & local table fails

Open dstala opened this issue 2 years ago • 2 comments

Please confirm if bug report does NOT exists already ?

  • [X] I confirm there is no existing issue for this

Steps to reproduce ?

Reported by discord user, reproducible when tried on staging https://discord.com/channels/661905455894888490/661905455894888493/1207542892671930423

  • Records are getting linked, but there is an issue when executing the updateLastModified function in BaseModelSqlv2 class.

  • If we try adding link from local table

{
    "message": "The column 'id' does not exist.",
    "type": "COLUMN_NOT_EXIST",
    "extra": {
        "column": "id"
    },
    "info": {
        "message": "update \"pf4o1rmzaiv4wy0\".\"Producer_2\" set \"updated_at\" = '2024-02-15 05:16:00+00:00', \"updated_by\" = 'uspck40ftp1krcsk' where (\"id\" = 'rec7CflqABElKe2iz') - column \"id\" does not exist",
        "code": "42703"
    }
}
  • If we try adding link from airtable imported table which has composite key
{
    "message": "The column 'ncRecordId' does not exist.",
    "type": "COLUMN_NOT_EXIST",
    "extra": {
        "column": "ncRecordId"
    },
    "info": {
        "message": "update \"pf4o1rmzaiv4wy0\".\"Table-1\" set \"updated_at\" = '2024-02-15 05:28:20+00:00', \"updated_by\" = 'uspck40ftp1krcsk' where (\"ncRecordId\" = '2') - column \"ncRecordId\" does not exist",
        "code": "42703"
    }
}

Desired Behavior

should be able to create links

Project Details

0.204.0

Attachments

No response

dstala avatar Feb 15 '24 04:02 dstala

Linking failed: The column 'ncRecordId' does not exist.

dstala avatar Feb 15 '24 04:02 dstala

@pranavxc this is the same issue we discussed earlier

  1. After links are getting added we updating column last modified both child and parent column
 await this.updateLastModified({
  model: parentTable,
  rowIds: [childId],
  cookie,
});
await this.updateLastModified({
  model: childTable,
  rowIds: [rowId],
  cookie,
});
  1. Inside updateLastModified function we doing something like below
    for (const rowId of Array.isArray(rowIds) ? rowIds : [rowIds]) {
      qb.orWhere(await this._wherePk(rowId));
    }

and inside this._wherePk() we using this.model instead of whatever model has been passed as props like parentTable and childTable model this are different

  async _wherePk(id) {
    await this.model.getColumns();
    return _wherePk(this.model.primaryKeys, id);
  }
  1. Last time we tried to fixed this but some other issue occurred, in frontend rows are getting reorderd according to updated_at but in frontend add new record modal is alway open but current row cell changes due to that record are getting added in some different cell

rameshmane7218 avatar Feb 15 '24 05:02 rameshmane7218

Already fixed in latest develop, earlier it was extracting primary key from wrong table and which caused the issue.

pranavxc avatar Jun 05 '24 09:06 pranavxc