Merge branch 'main' into next

This commit is contained in:
nocobase[bot] 2025-03-07 03:36:55 +00:00
commit af4959cee7
3 changed files with 32 additions and 6 deletions

View File

@ -424,16 +424,34 @@ export const querySchema: ISchema = {
order: { order: {
type: 'string', type: 'string',
'x-decorator': 'FormItem', 'x-decorator': 'FormItem',
'x-component': 'Radio.Group', 'x-component': 'Select',
'x-component-props': { 'x-component-props': {
defaultValue: 'ASC', defaultValue: 'ASC',
optionType: 'button',
style: {
width: '128px',
},
}, },
enum: ['ASC', 'DESC'], enum: ['ASC', 'DESC'],
}, },
nulls: {
type: 'string',
'x-decorator': 'FormItem',
'x-component': 'Select',
'x-component-props': {
defaultValue: 'default',
},
enum: [
{
label: lang('Default'),
value: 'default',
},
{
label: lang('NULLS first'),
value: 'first',
},
{
label: lang('NULLS last'),
value: 'last',
},
],
},
}, },
{ {
'x-reactions': '{{ useOrderReaction }}', 'x-reactions': '{{ useOrderReaction }}',

View File

@ -84,7 +84,14 @@ export class QueryParser {
orders.forEach((item: OrderProps) => { orders.forEach((item: OrderProps) => {
const alias = sequelize.getQueryInterface().quoteIdentifier(item.alias); const alias = sequelize.getQueryInterface().quoteIdentifier(item.alias);
const name = hasAgg ? sequelize.literal(alias) : sequelize.col(item.field as string); const name = hasAgg ? sequelize.literal(alias) : sequelize.col(item.field as string);
order.push([name, item.order || 'ASC']); let sort = item.order || 'ASC';
if (item.nulls === 'first') {
sort += ' NULLS FIRST';
}
if (item.nulls === 'last') {
sort += ' NULLS LAST';
}
order.push([name, sort]);
}); });
return order; return order;
} }

View File

@ -27,6 +27,7 @@ export type OrderProps = {
field: string | string[]; field: string | string[];
alias?: string; alias?: string;
order?: 'asc' | 'desc'; order?: 'asc' | 'desc';
nulls?: 'default' | 'first' | 'last';
}; };
export type QueryParams = Partial<{ export type QueryParams = Partial<{