From aba434e7e05f9288a5e2d3c2b73ef12921081021 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Sun, 21 Apr 2024 14:51:03 +0200 Subject: [PATCH] Clarify join result types in docs --- docs/lib/snippets/dart_api/select.dart | 5 ++--- docs/pages/docs/Dart API/select.md | 4 ++-- drift/lib/src/runtime/executor/helpers/engines.dart | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/lib/snippets/dart_api/select.dart b/docs/lib/snippets/dart_api/select.dart index 937f9a09..7752f78b 100644 --- a/docs/lib/snippets/dart_api/select.dart +++ b/docs/lib/snippets/dart_api/select.dart @@ -9,6 +9,8 @@ import '../_shared/todo_tables.drift.dart'; class EntryWithCategory { EntryWithCategory(this.entry, this.category); + // The classes are generated by drift for each of the tables involved in the + // join. final TodoItem entry; final Category? category; } @@ -69,8 +71,6 @@ extension SelectExamples on CanUseCommonTables { leftOuterJoin(categories, categories.id.equalsExp(todoItems.category)), ]); - // see next section on how to parse the result - // #enddocregion joinIntro // #docregion results return query.watch().map((rows) { return rows.map((row) { @@ -81,7 +81,6 @@ extension SelectExamples on CanUseCommonTables { }).toList(); }); // #enddocregion results - // #docregion joinIntro } // #enddocregion joinIntro diff --git a/docs/pages/docs/Dart API/select.md b/docs/pages/docs/Dart API/select.md index b26f3bfe..88e308a7 100644 --- a/docs/pages/docs/Dart API/select.md +++ b/docs/pages/docs/Dart API/select.md @@ -114,14 +114,14 @@ Of course, you can also join multiple tables: {% include "blocks/snippet" snippets = snippets name = 'otherTodosInSameCategory' %} -## Parsing results +### Parsing results Calling `get()` or `watch` on a select statement with join returns a `Future` or `Stream` of `List`, respectively. Each `TypedResult` represents a row from which data can be read. It contains a `rawData` getter to obtain the raw columns. But more importantly, the `readTable` method can be used to read a data class from a table. -In the example query above, we can read the todo entry and the category from each row like this: +In the example query above, we've read the todo entry and the category from each row like this: {% include "blocks/snippet" snippets = snippets name = 'results' %} diff --git a/drift/lib/src/runtime/executor/helpers/engines.dart b/drift/lib/src/runtime/executor/helpers/engines.dart index bb488ea7..47365c4e 100644 --- a/drift/lib/src/runtime/executor/helpers/engines.dart +++ b/drift/lib/src/runtime/executor/helpers/engines.dart @@ -140,7 +140,7 @@ abstract class _TransactionExecutor extends _BaseExecutor if (_closed) { throw StateError( - "A tranaction was used after being closed. Please check that you're " + "A transaction was used after being closed. Please check that you're " 'awaiting all database operations inside a `transaction` block.'); } }