Changelog History
Page 1
-
v0.24 Changes
October 28, 2021๐ฅ BREAKING CHANGES
Q.experimentalSortBy
,Q.experimentalSkip
,Q.experimentalTake
have been renamed toQ.sortBy
,Q.skip
,Q.take
respectively- โก๏ธ RxJS has been updated to 7.3.0. If you're not importing from
rxjs
in your app, this doesn't apply to you. If you are, read RxJS 7 breaking changes: https://rxjs.dev/deprecations/breaking-changes
๐ New features
- LocalStorage.
database.localStorage
is now available - sortBy, skip, take are now available in LokiJSAdapter as well
- Disposable records. Read-only records that cannot be saved in the database, updated, or deleted and only exist for as long as you keep a reference to them in memory can now be created using
collection.disposableFromDirtyRaw()
. This is useful when you're adding online-only features to an otherwise offline-first app. - ๐ [Sync]
experimentalRejectedIds
parameter now available in push response to allow partial rejection of an otherwise successful sync
๐ Fixes
- ๐ Fixes an issue when using Headless JS on Android with JSI mode enabled - pass
usesExclusiveLocking: true
to SQLiteAdapter to enable - ๐ Fixes Typescript annotations for Collection and adapters/sqlite
-
v0.23 Changes
July 22, 2021๐ This is a big release to WatermelonDB with new advanced features, great performance improvements, and important fixes to JSI on Android.
โฌ๏ธ Please don't get scared off the long list of breaking changes - they are all either simple Find&Replace renames or changes to internals you probably don't use. It shouldn't take you more than 15 minutes to upgrade to 0.23.
๐ฅ BREAKING CHANGES
- iOS Installation change. You need to add this line to your Podfile:
pod 'simdjson', path: '../node_modules/@nozbe/simdjson'
- ๐ Deprecated
new Database({ actionsEnabled: false })
options is now removed. Actions are always enabled. - ๐ Deprecated
new SQLiteAdapter({ synchronous: true })
option is now removed. Use{ jsi: true }
instead. - ๐ Deprecated
Q.unsafeLokiFilter
is now removed. UseQ.unsafeLokiTransform((raws, loki) => raws.filter(raw => ...))
instead. - ๐ Deprecated
Query.hasJoins
is now removed - ๐ Changes to
LokiJSAdapter
constructor options:indexedDBSerializer
->extraIncrementalIDBOptions: { serializeChunk, deserializeChunk }
onIndexedDBFetchStart
->extraIncrementalIDBOptions: { onFetchStart }
onIndexedDBVersionChange
->extraIncrementalIDBOptions: { onversionchange }
autosave: false
->extraLokiOptions: { autosave: false }
- ๐ Changes to Internal APIs. These were never meant to be public, and so are unlikely to affect you:
Model._isCommited
,._hasPendingUpdate
,._hasPendingDelete
have been removed and changed toModel._pendingState
Collection.unsafeClearCache()
is no longer exposed
- Values passed to
adapter.setLocal()
are now validated to be strings. This is technically a bug fix, since local storage was always documented to only accept strings, however applications may have relied on this lack of validation. Adding this validation was necessary to achieve consistent behavior between SQLiteAdapter and LokiJSAdapter - ๐
unsafeSql
passed toappSchema
will now also be called when dropping and later recreating all database indices on large batches. A second argument was added so you can distinguish between these cases. See Schema docs for more details. - ๐ Changes to sync change tracking. The behavior of
record._raw._changed
andrecord._raw._status
(a.k.a.record.syncStatus
) has changed. This is unlikely to be a breaking change to you, unless you're writing your own sync engine or rely on these low-level details.- Previously, _changed was always empty when _status=created. Now, _changed is not populated during initial creation of a record, but a later update will add changed fields to _changed. This change was necessary to fix a long-standing Sync bug.
๐ Deprecations
- ๐
database.action(() => {})
is now deprecated. Usedb.write(() => {})
instead (ordb.read(() => {})
if you only need consistency but are not writing any changes to DB) - ๐
@action
is now deprecated. Use@writer
or@reader
instead - ๐
.subAction()
is now deprecated. Use.callReader()
or.callWriter()
instead - ๐
Collection.unsafeFetchRecordsWithSQL()
is now deprecated. Usecollection.query(Q.unsafeSqlQuery("select * from...")).fetch()
instead.
๐ New features
db.write(writer => { ... writer.batch() })
- you can now call batch on the interface passed to a writer block- Fetching record IDs and unsafe raws. You can now optimize fetching of queries that only require IDs, not full cached records:
await query.fetchIds()
will return an array of record idsawait query.unsafeFetchRaw()
will return an array of unsanitized, unsafe raw objects (use alongsideQ.unsafeSqlQuery
to exclude unnecessary or include extra columns)- advanced
adapter.queryIds()
,adapter.unsafeQueryRaw
are also available
- Raw SQL queries. New syntax for running unsafe raw SQL queries:
collection.query(Q.unsafeSqlQuery("select * from tasks where foo = ?", ['bar'])).fetch()
- You can now also run
.fetchCount()
,.fetchIds()
on SQL queries - You can now safely pass values for SQL placeholders by passing an array
- You can also observe an unsafe raw SQL query -- with some caveats! refer to documentation for more details
- Unsafe raw execute. You can now execute arbitrary SQL queries (SQLiteAdapter) or access Loki object directly (LokiJSAdapter) using
adapter.unsafeExecute
-- see docs for more details - Turbo Login. You can now speed up the initial (login) sync by up to 5.3x with Turbo Login. See Sync docs for more details.
- ๐จ New diagnostic tool - debugPrintChanges. See Sync documentation for more details
๐ Performance
- The order of Q. clauses in a query is now preserved - previously, the clauses could get rearranged and produce a suboptimal query
- โก๏ธ [SQLite]
adapter.batch()
with large numbers of created/updated/deleted records is now between 16-48% faster - [LokiJS] Querying and finding is now faster - unnecessary data copy is skipped
- [jsi] 15-30% faster querying on JSC (iOS) when the number of returned records is large
- [jsi] up to 52% faster batch creation (yes, that's on top of the improvement listed above!)
- ๐ Fixed a performance bug that caused observed items on a list observer with
.observeWithColumns()
to be unnecessarily re-rendered just before they were removed from the list
๐ Changes
- ๐ All Watermelon console logs are prepended with a ๐ tag
- Extra protections against improper use of writers/readers (formerly actions) have been added
- โ Queries with multiple top-level
Q.on('table', ...)
now produce a warning. UseQ.on('table', [condition1, condition2, ...])
syntax instead. - [jsi] WAL mode is now used
๐ Fixes
- [jsi] Fix a race condition where commands sent to the database right after instantiating SQLiteAdapter would fail
- [jsi] Fix incorrect error reporting on some sqlite errors
- [jsi] Fix issue where app would crash on Android/Hermes on reload
- [jsi] Fix IO errors on Android
- โก๏ธ [sync] Fixed a long-standing bug that would cause records that are created before a sync and updated during sync's push to lose their most recent changes on a subsequent sync
Internal
- Internal changes to SQLiteAdapter:
- .batch is no longer available on iOS implementation
- .batch/.batchJSON internal format has changed
- .getDeletedRecords, destroyDeletedRecords, setLocal, removeLocal is no longer available
- encoded SQLiteAdapter schema has changed
- LokiJSAdapter has had many internal changes
- iOS Installation change. You need to add this line to your Podfile:
-
v0.22 Changes
May 07, 2021๐ฅ BREAKING CHANGES
- [SQLite]
experimentalUseJSI: true
option has been renamed tojsi: true
๐ Deprecations
- ๐ [LokiJS]
Q.unsafeLokiFilter
is now deprecated and will be removed in a future version. UseQ.unsafeLokiTransform((raws, loki) => raws.filter(raw => ...))
instead.
๐ New features
- ๐ [SQLite] [JSI]
jsi: true
now works on Android - see docs for installation info
๐ Performance
- โ Removed dependency on rambdax and made the util library smaller
- Faster withObservables
๐ Changes
- ๐ Synchronization:
pushChanges
is optional, will not calculate local changes if not specified. - โก๏ธ withObservables is now a dependency of WatermelonDB for simpler installation and consistent updates. You can (and generally should) delete
@nozbe/with-observables
from your app's package.json - ๐ [Docs] Add advanced tutorial to share database across iOS targets - @thiagobrez
- [SQLite] Allowed callbacks (within the migrationEvents object) to be passed so as to track the migration events status ( onStart, onSuccess, onError ) - @avinashlng1080
- [SQLite] Added a dev-only
Query._sql()
method for quickly extracting SQL from Queries for debugging purposes
๐ Fixes
- Non-react statics hoisting in
withDatabase()
- ๐ Fixed incorrect reference to
process
, which can break apps in some environments (e.g. webpack5) - ๐ [SQLite] [JSI] Fixed JSI mode when running on Hermes
- ๐ Fixed a race condition when using standard fetch methods alongside
Collection.unsafeFetchRecordsWithSQL
- @jspizziri - withObservables shouldn't cause any RxJS issues anymore as it no longer imports RxJS
- ๐ [Typescript] Added
onSetUpError
andonIndexedDBFetchStart
fields toLokiAdapterOptions
; fixes TS error - @3DDario - ๐ [Typescript] Removed duplicated identifiers
useWebWorker
anduseIncrementalIndexedDB
inLokiAdapterOptions
- @3DDario - 0๏ธโฃ [Typescript] Fix default export in logger util
- [SQLite]
-
v0.21 Changes
March 24, 2021๐ฅ BREAKING CHANGES
- โ [LokiJS]
useWebWorker
anduseIncrementalIndexedDB
options are now required (previously, skipping them would only trigger a warning)
๐ New features
- โก๏ธ [Model]
Model.update
method now returns updated record - ๐ฒ [adapters]
onSetUpError: Error => void
option is added to bothSQLiteAdapter
andLokiJSAdapter
. Supply this option to catch initialization errors and offer the user to reload or log out - [LokiJS] new
extraLokiOptions
andextraIncrementalIDBOptions
options - ๐ [Android] Autolinking is now supported.
- If You upgrade to
<= v0.21.0
AND are on a version of React Native which supports Autolinking, you will need to remove the config manually linking WatermelonDB. - You can resolve this issue by REMOVING the lines of config from your project which are added in the
Manual Install ONLY
section of the Android Install docs.
- If You upgrade to
๐ Performance
- ๐ [LokiJS] Improved performance of launching the app
๐ Changes
- ๐ [LokiJS]
useWebWorker: true
anduseIncrementalIndexedDB: false
options are now deprecated. If you rely on these features, please file an issue! - ๐ [Sync] Optional
log
passed to sync now has more helpful diagnostic information - ๐ [Sync] Open-sourced a simple SyncLogger you can optionally use. See docs for more info.
- ๐ [SQLiteAdapter]
synchronous:true
option is now deprecated and will be replaced withexperimentalUseJSI: true
in the future. Please test if your app compiles and works well withexperimentalUseJSI: true
, and if not - file an issue! - 0๏ธโฃ [LokiJS] Changed default autosave interval from 250 to 500ms
- [Typescript] Add
experimentalNestedJoin
definition andunsafeSqlExpr
clause
๐ Fixes
- ๐ [LokiJS] Fixed a case where IndexedDB could get corrupted over time
- [Resilience] Added extra diagnostics for when you encounter the
Record ID aa#bb was sent over the bridge, but it's not cached
error and a recovery path (LokiJSAdapter-only). Please file an issue if you encounter this issue! - ๐ [Typescript] Fixed type on OnFunction to accept
and
in join - ๐ [Typescript] Fixed type
database#batch(records)
's argumentrecords
to accept mixed types
Internal
- โ Added an experimental mode where a broken database state is detected, further mutations prevented, and the user notified
- โ [LokiJS]
-
v0.20 Changes
October 05, 2020๐ฅ BREAKING CHANGES
๐ This release has unintentionally broken RxJS for some apps using
with-observables
. If you have this issue, please update@nozbe/with-observables
to the latest version.๐ New features
- ๐ [Sync] Conflict resolution can now be customized. See docs for more details
- ๐ [Android] Autolinking is now supported
- ๐ง [LokiJS] Adapter autosave option is now configurable
๐ Changes
- ๐จ Interal RxJS imports have been refactor such that rxjs-compat should never be used now
- ๐ [Performance] Tweak Babel config to produce smaller code
- ๐ [Performance] LokiJS-based apps will now take up to 30% less time to load the database (id and unique indicies are generated lazily)
๐ Fixes
- ๐ [iOS] Fixed crash on database reset in apps linked against iOS 14 SDK
- ๐ [LokiJS] Fix
Q.like
being broken for multi-line strings on web - ๐ Fixed warn "import cycle" from DialogProvider (#786) by @gmonte.
- ๐ Fixed cache date as instance of Date (#828) by @djorkaeffalexandre.
-
v0.19 Changes
August 17, 2020๐ New features
- ๐ [iOS] Added CocoaPods support - @leninlin
- [NodeJS] Introducing a new SQLite Adapter based integration to NodeJS. This requires a ๐ peer dependency on better-sqlite3 ๐ง and should work with the same configuration as iOS/Android - @sidferreira
- ๐ [Android]
exerimentalUseJSI
option has been enabled on Android. However, it requires some app-specific setup which is not yet documented - stay tuned for upcoming releases - ๐ [Schema] [Migrations] You can now pass
unsafeSql
parameters to schema builder and migration steps to modify SQL generated to set up the database or perform migrations. There's also newunsafeExecuteSql
migration step. Please use this only if you know what you're doing โ you shouldn't need this in 99% of cases. See Schema and Migrations docs for more details - ๐ [LokiJS] [Performance] Added experimental
onIndexedDBFetchStart
andindexedDBSerializer
options toLokiJSAdapter
. These can be used to improve app launch time. Seesrc/adapters/lokijs/index.js
for more details.
๐ Changes
- ๐ [Performance] findAndObserve is now able to emit a value synchronously. By extension, this makes Relations put into withObservables able to render the child component in one shot. Avoiding the extra unnecessary render cycles avoids a lot of DOM and React commit-phase work, which can speed up loading some views by 30%
- ๐ [Performance] LokiJS is now faster (refactored encodeQuery, skipped unnecessary clone operations)
-
v0.18 Changes
June 30, 2020๐ Another WatermelonDB release after just a week? Yup! And it's jam-packed full of features!
๐ New features
[Query]
Q.on
queries are now far more flexible. Previously, they could only be placed at the top level of a query. See Docs for more details. Now, you can:Pass multiple conditions on the related query, like so:
collection.query( Q.on('projects', [ Q.where('foo', 'bar'), Q.where('bar', 'baz'), ]) )
You can place
Q.on
deeper inside the query (nested insideQ.and()
,Q.or()
). However, you must explicitly list all tables you're joining on at the beginning of a query, using:Q.experimentalJoinTables(['join_table1', 'join_table2'])
.You can nest
Q.on
conditions insideQ.on
, e.g. to make a condition on a grandchild. To do so, it's required to passQ.experimentalNestedJoin('parent_table', 'grandparent_table')
at the beginning of a query
[Query]
Q.unsafeSqlExpr()
andQ.unsafeLokiExpr()
are introduced to allow adding bits of queries that are not supported by the WatermelonDB query language without having to useunsafeFetchRecordsWithSQL()
. See docs for more details[Query]
Q.unsafeLokiFilter((rawRecord, loki) => boolean)
can now be used as an escape hatch to make queries with LokiJSAdapter that are not otherwise possible (e.g. multi-table column comparisons). See docs for more details
๐ Changes
- ๐ [Performance] [LokiJS] Improved performance of queries containing query comparisons on LokiJSAdapter
- ๐ [Docs] Added Contributing guide for Query language improvements
- ๐ [Deprecation]
Query.hasJoins
is deprecated - [DX] Queries with bad associations now show more helpful error message
- [Query] Counting queries that contain
Q.experimentalTake
/Q.experimentalSkip
is currently broken - previously it would return incorrect results, but now it will throw an error to avoid confusion. Please contribute to fix the root cause!
๐ Fixes
- ๐ [Typescript] Fixed types of Relation
Internal
QueryDescription
structure has been changed.
-
v0.17.1 Changes
June 24, 2020- ๐ Fixed broken iOS build - @mlecoq
-
v0.17 Changes
June 22, 2020๐ New features
- ๐ [Sync] Introducing Migration Syncs - this allows fully consistent synchronization when migrating between schema versions. Previously, there was no mechanism to incrementally fetch all remote changes in new tables and columns after a migration - so local copy was likely inconsistent, requiring a re-login. After adopting migration syncs, Watermelon Sync will request from backend all missing information. See Sync docs for more details.
[iOS] Introducing a new native SQLite database integration, rewritten from scratch in C++, based on React Native's JSI (JavaScript Interface). It is to be considered experimental, however we intend to make it the default (and eventually, the only) implementation. In a later release, Android version will be introduced.
The new adapter is up to 3x faster than the previously fastest
synchronous: true
option, however this speedup is only achieved with some unpublished React Native patches.To try out JSI, add
experimentalUseJSI: true
toSQLiteAdapter
constructor.[Query] Added
Q.experimentalSortBy(sortColumn, sortOrder)
,Q.experimentalTake(count)
,Q.experimentalSkip(count)
methods (only availble with SQLiteAdapter) - @Kenneth-KTDatabase.batch()
can now be called with a single array of models[DX]
Database.get(tableName)
is now a shortcut forDatabase.collections.get(tableName)
[DX] Query is now thenable - you can now use
await query
andawait query.count
instead ofawait query.fetch()
andawait query.fetchCount()
[DX] Relation is now thenable - you can now use
await relation
instead ofawait relation.fetch()
[DX] Exposed
collection.db
andmodel.db
as shortcuts to get to their Database object
๐ Changes
- [Hardening] Column and table names starting with
__
, Object property names (e.g.constructor
), and some reserved keywords are now forbidden - ๐ [DX] [Hardening] QueryDescription builder methods do tighter type checks, catching more bugs, and preventing users from unwisely passing unsanitized user data into Query builder methods
- [DX] [Hardening] Adapters check early if table names are valid
- [DX] Collection.find reports an error more quickly if an obviously invalid ID is passed
- [DX] Intializing Database with invalid model classes will now show a helpful error
- [DX] DatabaseProvider shows a more helpful error if used improperly
- ๐ [Sync] Sync no longer fails if pullChanges returns collections that don't exist on the frontend - shows a warning instead. This is to make building backwards-compatible backends less error-prone
- ๐ [Sync] [Docs] Sync documentation has been rewritten, and is now closer in detail to a formal specification
- ๐ [Hardening] database.collections.get() better validates passed value
- [Hardening] Prevents unsafe strings from being passed as column name/table name arguments in QueryDescription
๐ Fixes
- ๐ [Sync] Fixed
RangeError: Maximum call stack size exceeded
when syncing large amounts of data - @leninlin - ๐ [iOS] Fixed a bug that could cause a database operation to fail with an (6) SQLITE_LOCKED error
- ๐ [iOS] Fixed 'jsi/jsi.h' file not found when building at the consumer level. Added path
$(SRCROOT)/../../../../../ios/Pods/Headers/Public/React-jsi
to Header Search Paths (issue #691) - @victorbutler - [Native] SQLite keywords used as table or column names no longer crash
- ๐ Fixed potential issues when subscribing to database, collection, model, queries passing a subscriber function with the same identity more than once
Internal
- ๐ Fixed broken adapter tests
-
v0.17.0-7
June 18, 2020