- Published on
Release: Presto cache rewritten
- Authors
- Name
- Dave Coates
This release contains changes up until release/2022-02-15
.
To upgrade any existing projects it's recommended to pull in the relevant commits from upstream.
git remote add upstream git@gitlab.internal.alliancesoftware.com.au:alliance/template-django.git
git cherry-pick XXX1 XXX2
In cases where you are significantly behind it may be easier to pull the whole app (eg. common_audit
) in but you'll
need to review the relevant branch.
In this release
Presto rewritten cache
The Presto cache has been rewritten to resolve some long standing bugs and simplify the implementation to make ongoing maintenance easier. The typescript types are much more comprehensive but have resulted in some interface changes.
Upgrade codegen by pulling in this commit
- This will handle creating any new models. For existing descendant models (ie. not the
generated/*
models) you will need to manually update them (or delete them and re-generate if they have no changes from the default)
- This will handle creating any new models. For existing descendant models (ie. not the
viewModelFactory
now requires you to specify the primary key field anpkFieldName
option explicitly. If you have any models manually created you'll need to update them to do this but for most cases it's already handled by codegen.// This (no explicit primary key) class BaseMyModel extends viewModelFactory({ name: new CharField()}) {} // Becomes this class BaseMyModel extends viewModelFactory({ id: new IntegerField(), name: new CharField() }, { pkFieldName: 'id' }) { }) {}
When you
augment
a model you get better type info if you specify thepkFieldName
option again even if it's unchanged.// This class MyModel extends BaseMyModel.augment({}) {} // Becomes class MyModel extends BaseMyModel.augment({}, { pkFieldName: 'id' }) {}
To get proper typing on the viewModel
cache
property is slightly awkward but handled by codegen. To update existing models change:import ViewModelCache from '../core/ViewModelCache' import BaseBrand from './generated/BaseBrand' export default class Brand extends BaseBrand.augment({}) { static cache: ViewModelCache<typeof Brand> = new ViewModelCache(Brand) }
to
import { ViewModelCache as BaseViewModelCache } from '@prestojs/viewmodel' import ViewModelCache from '../core/ViewModelCache' import BaseBrand from './generated/BaseBrand' export default class Brand extends BaseBrand.augment({}, { pkFieldName: 'id' }) { static cache: BaseViewModelCache<typeof Brand> = new ViewModelCache<typeof Brand>(Brand) }
If you used the
ViewModelConstructor
type directly likeViewModelConstructor<any, any, any>
it now only has two generic types. Change this toViewModelConstructor<any, any>
.For examples of how to update existing code see this commit
See the changelog for more details.
Version 0.0.26 was also released which just makes final-form
and react-final-form
peer dependencies of @prestojs/final-form
. This prevents
issues with having multiple versions of the package loaded which breaks React context.
Other changes
- 8da17071 Page size is now explicitly returned in the default paginator. This resolves issues with Presto pagination & ant tables when there's only a single page available.
- b62f4d23 Lint python version regex fix for 3.10+ (thanks Vitaly)
- 23928a91 Fix no-shadow typescript lint (the default rule triggers a false-positive result for enums)
- 57b3caab
resolve_no_evaluator
added to CSV permissionsresolve_evaluators
. This allows you to write 'no' instead of leaving the column blank.