Browse Source

Merge pull request #4435 from nocodb/fix/query-field

fix: query field
pull/4405/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
f5ea771db9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      packages/nc-gui/composables/useViewData.ts
  2. 21
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

8
packages/nc-gui/composables/useViewData.ts

@ -189,6 +189,14 @@ export function useViewData(
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value }) : await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value })
formattedData.value = formatData(response.list) formattedData.value = formatData(response.list)
paginationData.value = response.pageInfo paginationData.value = response.pageInfo
// to cater the case like when querying with a non-zero offset
// the result page may point to the target page where the actual returned data don't display on
const expectedPage = Math.max(1, Math.ceil(paginationData.value.totalRows! / paginationData.value.pageSize!))
if (expectedPage < paginationData.value.page!) {
await changePage(expectedPage)
}
if (viewMeta.value?.type === ViewTypes.GRID) { if (viewMeta.value?.type === ViewTypes.GRID) {
await loadAggCommentsCount() await loadAggCommentsCount()
} }

21
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -175,7 +175,7 @@ class BaseModelSqlv2 {
sortArr?: Sort[]; sortArr?: Sort[];
sort?: string | string[]; sort?: string | string[];
} = {}, } = {},
ignoreFilterSort = false ignoreViewFilterAndSort = false
): Promise<any> { ): Promise<any> {
const { where, ...rest } = this._getListArgs(args as any); const { where, ...rest } = this._getListArgs(args as any);
@ -189,7 +189,7 @@ class BaseModelSqlv2 {
let sorts = extractSortsObject(rest?.sort, aliasColObjMap); let sorts = extractSortsObject(rest?.sort, aliasColObjMap);
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); const filterObj = extractFilterFromXwhere(where, aliasColObjMap);
// todo: replace with view id // todo: replace with view id
if (!ignoreFilterSort && this.viewId) { if (!ignoreViewFilterAndSort && this.viewId) {
await conditionV2( await conditionV2(
[ [
new Filter({ new Filter({
@ -249,7 +249,7 @@ class BaseModelSqlv2 {
qb.orderBy('created_at'); qb.orderBy('created_at');
} }
if (!ignoreFilterSort) applyPaginate(qb, rest); if (!ignoreViewFilterAndSort) applyPaginate(qb, rest);
const proto = await this.getProto(); const proto = await this.getProto();
const data = await this.extractRawQueryAndExec(qb); const data = await this.extractRawQueryAndExec(qb);
@ -261,7 +261,7 @@ class BaseModelSqlv2 {
public async count( public async count(
args: { where?: string; limit?; filterArr?: Filter[] } = {}, args: { where?: string; limit?; filterArr?: Filter[] } = {},
ignoreFilterSort = false ignoreViewFilterAndSort = false
): Promise<any> { ): Promise<any> {
await this.model.getColumns(); await this.model.getColumns();
const { where } = this._getListArgs(args); const { where } = this._getListArgs(args);
@ -272,7 +272,7 @@ class BaseModelSqlv2 {
const aliasColObjMap = await this.model.getAliasColObjMap(); const aliasColObjMap = await this.model.getAliasColObjMap();
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); const filterObj = extractFilterFromXwhere(where, aliasColObjMap);
if (!ignoreFilterSort && this.viewId) { if (!ignoreViewFilterAndSort && this.viewId) {
await conditionV2( await conditionV2(
[ [
new Filter({ new Filter({
@ -2474,7 +2474,7 @@ class BaseModelSqlv2 {
public async groupedList( public async groupedList(
args: { args: {
groupColumnId: string; groupColumnId: string;
ignoreFilterSort?: boolean; ignoreViewFilterAndSort?: boolean;
options?: (string | number | null | boolean)[]; options?: (string | number | null | boolean)[];
} & Partial<XcFilter> } & Partial<XcFilter>
): Promise< ): Promise<
@ -2527,7 +2527,7 @@ class BaseModelSqlv2 {
let sorts = extractSortsObject(args?.sort, aliasColObjMap); let sorts = extractSortsObject(args?.sort, aliasColObjMap);
const filterObj = extractFilterFromXwhere(where, aliasColObjMap); const filterObj = extractFilterFromXwhere(where, aliasColObjMap);
// todo: replace with view id // todo: replace with view id
if (!args.ignoreFilterSort && this.viewId) { if (!args.ignoreViewFilterAndSort && this.viewId) {
await conditionV2( await conditionV2(
[ [
new Filter({ new Filter({
@ -2640,7 +2640,10 @@ class BaseModelSqlv2 {
} }
public async groupedListCount( public async groupedListCount(
args: { groupColumnId: string; ignoreFilterSort?: boolean } & XcFilter args: {
groupColumnId: string;
ignoreViewFilterAndSort?: boolean;
} & XcFilter
) { ) {
const column = await this.model const column = await this.model
.getColumns() .getColumns()
@ -2659,7 +2662,7 @@ class BaseModelSqlv2 {
const filterObj = extractFilterFromXwhere(args.where, aliasColObjMap); const filterObj = extractFilterFromXwhere(args.where, aliasColObjMap);
// todo: replace with view id // todo: replace with view id
if (!args.ignoreFilterSort && this.viewId) { if (!args.ignoreViewFilterAndSort && this.viewId) {
await conditionV2( await conditionV2(
[ [
new Filter({ new Filter({

Loading…
Cancel
Save