Browse Source

Merge pull request #7500 from nocodb/nc-fix/groupby-formula-fields

Nc fix: Groupby doesn't work if formula field dataType is numeric
pull/7532/head
Raju Udava 9 months ago committed by GitHub
parent
commit
004fdd7c15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      packages/nc-gui/components/smartsheet/grid/GroupBy.vue
  2. 12
      packages/nocodb/src/db/conditionV2.ts

6
packages/nc-gui/components/smartsheet/grid/GroupBy.vue

@ -72,7 +72,7 @@ const findAndLoadSubGroup = (key: any) => {
if (grp.nested) { if (grp.nested) {
if (!grp.children?.length) props.loadGroups({}, grp) if (!grp.children?.length) props.loadGroups({}, grp)
} else { } else {
if (!grp.rows?.length) props.loadGroupData(grp) if (!grp.rows?.length || grp.count !== grp.rows?.length) props.loadGroupData(grp)
} }
} }
} }
@ -258,7 +258,9 @@ const shouldRenderCell = (column) =>
<div class="flex items-center"> <div class="flex items-center">
<div class="flex flex-col"> <div class="flex flex-col">
<div class="flex gap-2"> <div class="flex gap-2">
<div class="text-xs nc-group-column-title">{{ grp.column.title }}</div> <div class="text-xs nc-group-column-title">
{{ grp.column.title }}
</div>
<div class="text-xs text-gray-400 nc-group-row-count">({{ $t('datatype.Count') }}: {{ grp.count }})</div> <div class="text-xs text-gray-400 nc-group-row-count">({{ $t('datatype.Count') }}: {{ grp.count }})</div>
</div> </div>
<div class="flex mt-1"> <div class="flex mt-1">

12
packages/nocodb/src/db/conditionV2.ts

@ -1,4 +1,5 @@
import { import {
FormulaDataTypes,
isDateMonthFormat, isDateMonthFormat,
isNumericCol, isNumericCol,
RelationTypes, RelationTypes,
@ -447,7 +448,16 @@ const parseConditionV2 = async (
).builder; ).builder;
return parseConditionV2( return parseConditionV2(
baseModelSqlv2, baseModelSqlv2,
new Filter({ ...filter, value: knex.raw('?', [filter.value]) } as any), new Filter({
...filter,
value: knex.raw('?', [
// convert value to number if formulaDataType if numeric
formula.getParsedTree()?.dataType === FormulaDataTypes.NUMERIC &&
!isNaN(+filter.value)
? +filter.value
: filter.value ?? null, // in gp_null value is undefined
]),
} as any),
aliasCount, aliasCount,
alias, alias,
builder, builder,

Loading…
Cancel
Save