aqueduct icon indicating copy to clipboard operation
aqueduct copied to clipboard

Change behavior of ManagedSet.haveAtLeastOneWhere

Open itsjoeconway opened this issue 7 years ago • 4 comments

This is getting hung by by stricter type checks, and wasn't the best solution in the first place. The preferred solution would be have variants of this expression behavior, and to also remove its signature from ManagedSet because it is misleading.

Preliminary research has shown that a preferable API might be the following:

query.where((o) => o.children).have(anyOf: (child) => child.field).equalTo(...);
query.where((o) => o.children).have(noneOf: (child) => child.field).equalTo(...);
query.where((o) => o.children).have(allOf: (child) => child.field).equalTo(...);

Issues are that QueryExpression<T, U> expects to retain the type argument U (the object type being queried) throughout the expression chain, but this may be worth looking at if it is even viable.

itsjoeconway avatar Jul 03 '18 18:07 itsjoeconway

Hi @joeconwaystk - so as far as I understand

haveAtLeastOneWhere

has been removed and there is no replacement for it at the moment? If that's so then the doc probably should be updated https://aqueduct.io/docs/db/advanced_queries/

illia-romanenko avatar Sep 30 '19 14:09 illia-romanenko

@joeconwaystk Hello! I very need an example of usage without haveAtLeastOneWhere

kovac777 avatar Nov 02 '20 14:11 kovac777

Example:

var query = new Query<Team>(context)
  ..where((t) => t.players.haveAtLeastOneWhere.yearsPlayed).lessThanOrEqualTo(1);

var teamsWithRookies = await query.fetch();
  • https://aqueduct.io/docs/snippets/orm/

jayjah avatar Nov 02 '20 15:11 jayjah

@jayjah Yes, but haveAtLeastOneWhere was removed and now I don't see alter solutions

kovac777 avatar Nov 02 '20 16:11 kovac777