|
1 | 1 | # Migrating Between Major Versions
|
2 | 2 |
|
3 |
| -## Migrating from Brick 3 to Brick 4 |
| 3 | +In preparation for Brick 4, `Query` is migrating away from loosely-defined arguments in favor of standardized fields that can be easily deprecated and discovered by analysis. |
4 | 4 |
|
5 |
| -Brick 4 away from loosely-defined `Query` arguments in favor of standardized fields that can be easily deprecated and discovered by analysis. |
| 5 | +**`providerArgs` will be supported until Brick 4 is officially released**. |
6 | 6 |
|
7 |
| -### Breaking Changes |
| 7 | +It is still recommended you migrate to the new `Query` for new features and long-term support. |
8 | 8 |
|
9 |
| -**`providerArgs` will be supported until Brick 4 is officially released**. It is still recommended you migrate to the new `Query` for better `orderBy` and `limitBy`. |
| 9 | +## Improvements |
10 | 10 |
|
11 |
| -- `Query(providerArgs: {'limit':})` is now `Query(limit:)` |
12 |
| -- `Query(providerArgs: {'offset':})` is now `Query(offset:)` |
13 |
| -- `Query(providerArgs: {'orderBy':})` is now `Query(orderBy:)`. This is a more significant change than `limit` or `offset`. `orderBy` is now defined by a class that permits multiple commands. For example, `'orderBy': 'name ASC'` becomes `[OrderBy('name', ascending: true)]`. First-class Brick providers (SQLite and Supabase) also support association-based querying by declaring a `model:`. |
| 11 | +- `Query#orderBy` will support association ordering and multiple values |
| 12 | +- `Query` is constructed with `const` |
| 13 | +- `Query#offset` no longer requires companion `limit` parameter |
| 14 | +- `brick_sqlite` and `brick_supabase` support association ordering. For example, `Query(orderBy: [OrderBy.desc('assoc', associationField: 'name')])` on `DemoModel` will produce the following SQL statement: |
| 15 | + ```sql |
| 16 | + 'SELECT DISTINCT `DemoModel`.* FROM `DemoModel` ORDER BY `DemoModelAssoc`.name DESC' |
| 17 | + ``` |
| 18 | +- `brick_supabase` supports advanced limiting. For example, `Query(limitBy: [LimitBy(1, evaluatedField: 'assoc'))` is the equivalent of `.limit(1, referencedTable: 'demo_model')` |
14 | 19 |
|
15 |
| -#### brick_graphql |
| 20 | +## Universal Deprecations |
16 | 21 |
|
17 |
| -- `Query(providerArgs: {'context':})` is now `Query(forProviders: [GraphqlProviderQuery(context:)])` |
18 |
| -- `Query(providerArgs: {'operation':})` is now `Query(forProviders: [GraphqlProviderQuery(operation:)])` |
| 22 | +| Old | New | Notes | |
| 23 | +| ----------------------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 24 | +| `Query(providerArgs: {'limit':})` | `Query(limit:)` | `limit` and `limitBy` may be used together, however, `limitBy` will only limit `evaluatedField:` associations | |
| 25 | +| `Query(providerArgs: {'offset':})` | `Query(offset:)` | | |
| 26 | +| `Query(providerArgs: {'orderBy':})` | `Query(orderBy:)` | `orderBy` is now defined by a class that permits multiple commands. For example, `'orderBy': 'name ASC'` becomes `[OrderBy('name', ascending: true)]`. First-class Brick providers (SQLite and Supabase) also support association-based querying by declaring a `associationField:`. This `associationField` is optional in Supabase but required for `SQLite`. | |
19 | 27 |
|
20 |
| -#### brick_rest |
| 28 | +## Package-specific deprecations |
21 | 29 |
|
22 |
| -- `Query(providerArgs: {'request':})` is now `Query(forProviders: [RestProviderQuery(request:)])`. This is a similarly significant chang that allows providers to be detected by static analysis and reduces the need for manual documentation. |
| 30 | +### brick_graphql |
23 | 31 |
|
24 |
| -#### brick_sqlite |
| 32 | +| Old | New | Notes | |
| 33 | +| ------------------------------------- | --------------------------------------------------------- | ----- | |
| 34 | +| `Query(providerArgs: {'context':})` | `Query(forProviders: [GraphqlProviderQuery(context:)])` | |
| 35 | +| `Query(providerArgs: {'operation':})` | `Query(forProviders: [GraphqlProviderQuery(operation:)])` | |
25 | 36 |
|
26 |
| -- `Query(providerArgs: {'collate':})` is now `Query(forProviders: [SqliteProviderQuery(collate:)])` |
27 |
| -- `Query(providerArgs: {'having':})` is now `Query(forProviders: [SqliteProviderQuery(having:)])` |
28 |
| -- `Query(providerArgs: {'groupBy':})` is now `Query(forProviders: [SqliteProviderQuery(groupBy:)])` |
| 37 | +### brick_rest |
29 | 38 |
|
30 |
| -#### brick_supabase |
| 39 | +| Old | New | Notes | |
| 40 | +| ----------------------------------- | ---------------------------------------------------- | ----- | |
| 41 | +| `Query(providerArgs: {'request':})` | `Query(forProviders: [RestProviderQuery(request:)])` | | |
31 | 42 |
|
32 |
| -- `Query(providerArgs: {'limitReferencedTable':})` has been removed in favor of `Query(limitBy:)` |
33 |
| -- `Query(providerArgs: {'orderByReferencedTable':})` has been removed in favor of `Query(orderBy:)` |
| 43 | +### brick_sqlite |
34 | 44 |
|
35 |
| -### Improvements |
| 45 | +| Old | New | Notes | |
| 46 | +| ----------------------------------- | ------------------------------------------------------ | ----- | |
| 47 | +| `Query(providerArgs: {'collate':})` | `Query(forProviders: [SqliteProviderQuery(collate:)])` | |
| 48 | +| `Query(providerArgs: {'having':})` | `Query(forProviders: [SqliteProviderQuery(having:)])` | |
| 49 | +| `Query(providerArgs: {'groupBy':})` | `Query(forProviders: [SqliteProviderQuery(groupBy:)])` | |
36 | 50 |
|
37 |
| -- `OrderBy` will support association ordering and multiple values |
38 |
| -- `Query` is constructed with `const` |
39 |
| -- `Query#offset` no longer requires companion `limit` parameter |
40 |
| -- `brick_sqlite` and `brick_supabase` support association ordering. For example, `Query(orderBy: [OrderBy.desc('name', model: DemoModelAssoc)])` on `DemoModel` will produce the following SQL statement: |
41 |
| - ```sql |
42 |
| - 'SELECT DISTINCT `DemoModel`.* FROM `DemoModel` ORDER BY `DemoModelAssoc`.name DESC' |
43 |
| - ``` |
44 |
| -- `brick_supabase` supports advanced limiting. For example, `Query(limitBy: [LimitBy(1, model: DemoModel))` is the equivalent of `.limit(1, referencedTable: 'demo_model')` |
| 51 | +### brick_supabase |
| 52 | + |
| 53 | +| Old | New | Notes | |
| 54 | +| -------------------------------------------------- | --- | ------------------------------------- | |
| 55 | +| `Query(providerArgs: {'limitReferencedTable':})` | | Removed in favor of `Query(limitBy:)` | |
| 56 | +| `Query(providerArgs: {'orderByReferencedTable':})` | | Removed in favor of `Query(orderBy:)` | |
45 | 57 |
|
46 | 58 | ## Migrating from Brick 2 to Brick 3
|
47 | 59 |
|
|
0 commit comments