all/not all的逻辑修正

This commit is contained in:
Xu Chang 2025-08-22 16:48:23 +08:00
parent b494b94fe9
commit 5bd2f1c14c
5 changed files with 15 additions and 4 deletions

View File

@ -16,6 +16,7 @@ export declare class MysqlStore<ED extends EntityDict & BaseEntityDict, Cxt exte
connector: MySqlConnector; connector: MySqlConnector;
translator: MySqlTranslator<ED>; translator: MySqlTranslator<ED>;
constructor(storageSchema: StorageSchema<ED>, configuration: MySQLConfiguration); constructor(storageSchema: StorageSchema<ED>, configuration: MySQLConfiguration);
checkRelationAsync<T extends keyof ED, Cxt extends AsyncContext<ED>>(entity: T, operation: Omit<ED[T]['Operation'] | ED[T]['Selection'], 'id'>, context: Cxt): Promise<void>;
protected aggregateAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>; protected aggregateAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>; aggregate<T extends keyof ED, OP extends SelectOption>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>>;
protected supportManyToOneJoin(): boolean; protected supportManyToOneJoin(): boolean;

View File

@ -44,6 +44,9 @@ class MysqlStore extends CascadeStore_1.CascadeStore {
this.connector = new connector_1.MySqlConnector(configuration); this.connector = new connector_1.MySqlConnector(configuration);
this.translator = new translator_1.MySqlTranslator(storageSchema); this.translator = new translator_1.MySqlTranslator(storageSchema);
} }
checkRelationAsync(entity, operation, context) {
throw new Error('Method not implemented.');
}
async aggregateAbjointRowAsync(entity, aggregation, context, option) { async aggregateAbjointRowAsync(entity, aggregation, context, option) {
const sql = this.translator.translateAggregate(entity, aggregation, option); const sql = this.translator.translateAggregate(entity, aggregation, option);
const result = await this.connector.exec(sql, context.getCurrentTxnId()); const result = await this.connector.exec(sql, context.getCurrentTxnId());

View File

@ -635,7 +635,7 @@ class SqlTranslator {
*/ */
const joinFilter = { const joinFilter = {
$expr83: { $expr83: {
[['all', 'not all'].includes(predicate) ? '$ne' : '$eq']: [ '$eq': [
{ {
'#attr': fk, '#attr': fk,
}, },
@ -655,7 +655,9 @@ class SqlTranslator {
data: { data: {
id: 1, id: 1,
}, },
filter: (0, filter_1.combineFilters)(subEntity, this.schema, [joinFilter, filter2[attr]]), filter: (0, filter_1.combineFilters)(subEntity, this.schema, [joinFilter, {
$not: filter2[attr],
}]),
indexFrom: 0, indexFrom: 0,
count: 1, count: 1,
}, currentNumber, filterRefAlias, option); }, currentNumber, filterRefAlias, option);

View File

@ -53,6 +53,9 @@ export class MysqlStore<ED extends EntityDict & BaseEntityDict, Cxt extends Asyn
this.connector = new MySqlConnector(configuration); this.connector = new MySqlConnector(configuration);
this.translator = new MySqlTranslator(storageSchema); this.translator = new MySqlTranslator(storageSchema);
} }
checkRelationAsync<T extends keyof ED, Cxt extends AsyncContext<ED>>(entity: T, operation: Omit<ED[T]['Operation'] | ED[T]['Selection'], 'id'>, context: Cxt): Promise<void> {
throw new Error('Method not implemented.');
}
protected async aggregateAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>> { protected async aggregateAbjointRowAsync<T extends keyof ED, OP extends SelectOption, Cxt extends AsyncContext<ED>>(entity: T, aggregation: ED[T]['Aggregation'], context: Cxt, option: OP): Promise<AggregationResult<ED[T]['Schema']>> {
const sql = this.translator.translateAggregate(entity, aggregation, option); const sql = this.translator.translateAggregate(entity, aggregation, option);
const result = await this.connector.exec(sql, context.getCurrentTxnId()); const result = await this.connector.exec(sql, context.getCurrentTxnId());

View File

@ -810,7 +810,7 @@ export abstract class SqlTranslator<ED extends EntityDict & BaseEntityDict> {
*/ */
const joinFilter = { const joinFilter = {
$expr83: { $expr83: {
[['all', 'not all'].includes(predicate) ? '$ne' : '$eq']: [ '$eq': [
{ {
'#attr': fk, '#attr': fk,
}, },
@ -831,7 +831,9 @@ export abstract class SqlTranslator<ED extends EntityDict & BaseEntityDict> {
data: { data: {
id: 1, id: 1,
}, },
filter: combineFilters(subEntity, this.schema, [joinFilter, filter2[attr]]), filter: combineFilters(subEntity, this.schema, [joinFilter, {
$not: filter2[attr],
}]),
indexFrom: 0, indexFrom: 0,
count: 1, count: 1,
}, currentNumber, filterRefAlias, option); }, currentNumber, filterRefAlias, option);