Browse Source

Merge pull request #7017 from nocodb/fix/6823-data-api-v2-link

fix: Avoid treating value as column_name in sql join
pull/7035/head
Raju Udava 1 year ago committed by GitHub
parent
commit
ef94a45f57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      packages/nocodb/src/db/BaseModelSqlv2.ts

8
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -4679,10 +4679,11 @@ class BaseModelSqlv2 {
`${parentTable.table_name}.${parentColumn.column_name}`, `${parentTable.table_name}.${parentColumn.column_name}`,
).andOn( ).andOn(
`${vTable.table_name}.${vChildCol.column_name}`, `${vTable.table_name}.${vChildCol.column_name}`,
row[childColumn.column_name], this.dbDriver.raw('?', [
row[childColumn.title] ?? row[childColumn.column_name],
]),
); );
}); });
// .where(_wherePk(parentTable.primaryKeys, childId))
if (parentTable.primaryKeys.length > 1) { if (parentTable.primaryKeys.length > 1) {
childRowsQb.where((qb) => { childRowsQb.where((qb) => {
@ -4901,8 +4902,6 @@ class BaseModelSqlv2 {
const childTn = this.getTnPath(childTable); const childTn = this.getTnPath(childTable);
const parentTn = this.getTnPath(parentTable); const parentTn = this.getTnPath(parentTable);
// const prevData = await this.readByPk(rowId);
switch (colOptions.type) { switch (colOptions.type) {
case RelationTypes.MANY_TO_MANY: case RelationTypes.MANY_TO_MANY:
{ {
@ -5127,7 +5126,6 @@ class BaseModelSqlv2 {
parentCol.column_name, parentCol.column_name,
this.dbDriver(childTn) this.dbDriver(childTn)
.select(chilCol.column_name) .select(chilCol.column_name)
// .where(parentTable.primaryKey.cn, p)
.where(_wherePk(childTable.primaryKeys, id)), .where(_wherePk(childTable.primaryKeys, id)),
); );

Loading…
Cancel
Save