mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
af4959cee7
@ -424,16 +424,34 @@ export const querySchema: ISchema = {
|
||||
order: {
|
||||
type: 'string',
|
||||
'x-decorator': 'FormItem',
|
||||
'x-component': 'Radio.Group',
|
||||
'x-component': 'Select',
|
||||
'x-component-props': {
|
||||
defaultValue: 'ASC',
|
||||
optionType: 'button',
|
||||
style: {
|
||||
width: '128px',
|
||||
},
|
||||
},
|
||||
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 }}',
|
||||
|
@ -84,7 +84,14 @@ export class QueryParser {
|
||||
orders.forEach((item: OrderProps) => {
|
||||
const alias = sequelize.getQueryInterface().quoteIdentifier(item.alias);
|
||||
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;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ export type OrderProps = {
|
||||
field: string | string[];
|
||||
alias?: string;
|
||||
order?: 'asc' | 'desc';
|
||||
nulls?: 'default' | 'first' | 'last';
|
||||
};
|
||||
|
||||
export type QueryParams = Partial<{
|
||||
|
Loading…
x
Reference in New Issue
Block a user