Browse Source

fix: lint

pull/2535/head
Wing-Kam Wong 3 years ago
parent
commit
046a1f63b1
  1. 53
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts

53
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/conditionV2.ts

@ -50,11 +50,11 @@ const parseConditionV2 = async (
}
if (Array.isArray(_filter)) {
const qbs = await Promise.all(
_filter.map(child => parseConditionV2(child, knex, aliasCount))
_filter.map((child) => parseConditionV2(child, knex, aliasCount))
);
return qbP => {
qbP.where(qb => {
return (qbP) => {
qbP.where((qb) => {
for (const [i, qb1] of Object.entries(qbs)) {
qb[getLogicalOpMethod(_filter[i])](qb1);
}
@ -64,11 +64,11 @@ const parseConditionV2 = async (
const children = await filter.getChildren();
const qbs = await Promise.all(
(children || []).map(child => parseConditionV2(child, knex, aliasCount))
(children || []).map((child) => parseConditionV2(child, knex, aliasCount))
);
return qbP => {
qbP[getLogicalOpMethod(filter)](qb => {
return (qbP) => {
qbP[getLogicalOpMethod(filter)]((qb) => {
for (const [i, qb1] of Object.entries(qbs)) {
qb[getLogicalOpMethod(children[i])](qb1);
}
@ -78,7 +78,8 @@ const parseConditionV2 = async (
const column = await filter.getColumn();
if (!column) return () => {};
if (column.uidt === UITypes.LinkToAnotherRecord) {
const colOptions = (await column.getColOptions()) as LinkToAnotherRecordColumn;
const colOptions =
(await column.getColOptions()) as LinkToAnotherRecordColumn;
const childColumn = await colOptions.getChildColumn();
const parentColumn = await colOptions.getParentColumn();
const childModel = await childColumn.getModel();
@ -97,7 +98,7 @@ const parseConditionV2 = async (
? negatedMapping[filter.comparison_op]
: {}),
fk_model_id: childModel.id,
fk_column_id: childModel?.primaryValue?.id
fk_column_id: childModel?.primaryValue?.id,
}),
knex,
aliasCount
@ -121,7 +122,7 @@ const parseConditionV2 = async (
? negatedMapping[filter.comparison_op]
: {}),
fk_model_id: parentModel.id,
fk_column_id: parentModel?.primaryValue?.id
fk_column_id: parentModel?.primaryValue?.id,
}),
knex,
aliasCount
@ -153,7 +154,7 @@ const parseConditionV2 = async (
? negatedMapping[filter.comparison_op]
: {}),
fk_model_id: parentModel.id,
fk_column_id: parentModel?.primaryValue?.id
fk_column_id: parentModel?.primaryValue?.id,
}),
knex,
aliasCount
@ -167,7 +168,7 @@ const parseConditionV2 = async (
};
}
return _qb => {};
return (_qb) => {};
} else if (column.uidt === UITypes.Lookup) {
return await generateLookupCondition(column, filter, knex, aliasCount);
} else if (column.uidt === UITypes.Rollup && !customWhereClause) {
@ -175,7 +176,7 @@ const parseConditionV2 = async (
await genRollupSelectv2({
knex,
alias,
columnOptions: (await column.getColOptions()) as RollupColumn
columnOptions: (await column.getColOptions()) as RollupColumn,
})
).builder;
return parseConditionV2(
@ -213,7 +214,7 @@ const parseConditionV2 = async (
);
let val = customWhereClause ? customWhereClause : filter.value;
return qb => {
return (qb) => {
switch (filter.comparison_op) {
case 'eq':
qb = qb.where(field, val);
@ -321,7 +322,7 @@ const parseConditionV2 = async (
const negatedMapping = {
nlike: { comparison_op: 'like' },
neq: { comparison_op: 'eq' }
neq: { comparison_op: 'eq' },
};
function getAlias(aliasCount: { count: number }) {
@ -337,9 +338,8 @@ async function generateLookupCondition(
): Promise<any> {
const colOptions = await col.getColOptions<LookupColumn>();
const relationColumn = await colOptions.getRelationColumn();
const relationColumnOptions = await relationColumn.getColOptions<
LinkToAnotherRecordColumn
>();
const relationColumnOptions =
await relationColumn.getColOptions<LinkToAnotherRecordColumn>();
// const relationModel = await relationColumn.getModel();
const lookupColumn = await colOptions.getLookupColumn();
const alias = getAlias(aliasCount);
@ -362,7 +362,7 @@ async function generateLookupCondition(
...filter,
...(filter.comparison_op in negatedMapping
? negatedMapping[filter.comparison_op]
: {})
: {}),
},
lookupColumn,
qb,
@ -385,7 +385,7 @@ async function generateLookupCondition(
...filter,
...(filter.comparison_op in negatedMapping
? negatedMapping[filter.comparison_op]
: {})
: {}),
},
lookupColumn,
qb,
@ -419,7 +419,7 @@ async function generateLookupCondition(
...filter,
...(filter.comparison_op in negatedMapping
? negatedMapping[filter.comparison_op]
: {})
: {}),
},
lookupColumn,
qb,
@ -455,9 +455,8 @@ async function nestedConditionJoin(
await lookupColumn.getColOptions<LookupColumn>()
).getRelationColumn()
: lookupColumn;
const relationColOptions = await relationColumn.getColOptions<
LinkToAnotherRecordColumn
>();
const relationColOptions =
await relationColumn.getColOptions<LinkToAnotherRecordColumn>();
const relAlias = `__nc${aliasCount.count++}`;
const childColumn = await relationColOptions.getChildColumn();
@ -528,7 +527,7 @@ async function nestedConditionJoin(
new Filter({
...filter,
fk_model_id: childModel.id,
fk_column_id: childModel.primaryValue?.id
fk_column_id: childModel.primaryValue?.id,
}),
knex,
aliasCount,
@ -544,7 +543,7 @@ async function nestedConditionJoin(
new Filter({
...filter,
fk_model_id: parentModel.id,
fk_column_id: parentModel?.primaryValue?.id
fk_column_id: parentModel?.primaryValue?.id,
}),
knex,
aliasCount,
@ -560,7 +559,7 @@ async function nestedConditionJoin(
new Filter({
...filter,
fk_model_id: parentModel.id,
fk_column_id: parentModel.primaryValue?.id
fk_column_id: parentModel.primaryValue?.id,
}),
knex,
aliasCount,
@ -577,7 +576,7 @@ async function nestedConditionJoin(
new Filter({
...filter,
fk_model_id: (await lookupColumn.getModel()).id,
fk_column_id: lookupColumn?.id
fk_column_id: lookupColumn?.id,
}),
knex,
aliasCount,

Loading…
Cancel
Save