From 573bd20eb8f5e33a40ddcdc3b9ebbe91cbcfcd37 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 5 Jan 2022 18:52:35 +0100 Subject: [PATCH] Fix missing quotes in drift files docs --- .../docs/Advanced Features/builder_options.md | 2 +- .../docs/Getting started/starting_with_sql.md | 4 ++-- docs/pages/docs/Using SQL/custom_queries.md | 10 +++++----- .../Using SQL/{moor_files.md => drift_files.md} | 16 +++++++++------- docs/pages/v2.html | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) rename docs/pages/docs/Using SQL/{moor_files.md => drift_files.md} (98%) diff --git a/docs/pages/docs/Advanced Features/builder_options.md b/docs/pages/docs/Advanced Features/builder_options.md index 03ccac31..5b2a2d92 100644 --- a/docs/pages/docs/Advanced Features/builder_options.md +++ b/docs/pages/docs/Advanced Features/builder_options.md @@ -77,7 +77,7 @@ At the moment, drift supports these options: * `new_sql_code_generation`: Generates SQL statements from the parsed AST instead of replacing substrings. This will also remove unnecessary whitespace and comments. If enabling this option breaks your queries, please file an issue! -* `scoped_dart_components`: Generates a function parameter for [Dart placeholders]({{ '../Using SQL/moor_files.md#dart-components-in-sql' | pageUrl }}) in SQL. +* `scoped_dart_components`: Generates a function parameter for [Dart placeholders]({{ '../Using SQL/drift_files.md#dart-components-in-sql' | pageUrl }}) in SQL. The function has a parameter for each table that is available in the query, making it easier to get aliases right when using Dart placeholders. * `null_aware_type_converters`: Consider the type of applied type converters to determine nullability of columns in Dart. diff --git a/docs/pages/docs/Getting started/starting_with_sql.md b/docs/pages/docs/Getting started/starting_with_sql.md index 6a7a6302..4858307f 100644 --- a/docs/pages/docs/Getting started/starting_with_sql.md +++ b/docs/pages/docs/Getting started/starting_with_sql.md @@ -149,7 +149,7 @@ Let's take a look at what drift generated during the build: - a `Selectable todosInCategory(int)` method, which runs the `todosInCategory` query declared above. Drift has determined that the type of the variable in that query is `int`, because that's the type - of the `category` column we're comparing it to. + of the `category` column we're comparing it to. The method returns a `Selectable` to indicate that it can both be used as a regular query (`Selectable.get` returns a `Future>`) or as an auto-updating stream (by using `.watch` instead of `.get()`). @@ -169,7 +169,7 @@ further guides to help you learn more: - [Schema migrations]({{ "../Advanced Features/migrations.md" | pageUrl }}) - Writing [queries]({{ "writing_queries.md" | pageUrl }}) and [expressions]({{ "../Advanced Features/expressions.md" | pageUrl }}) in Dart -- A more [in-depth guide]({{ "../Using SQL/moor_files.md" | pageUrl }}) +- A more [in-depth guide]({{ "../Using SQL/drift_files.md" | pageUrl }}) on `drift` files, which explains `import` statements and the Dart-SQL interop. {% block "blocks/alert" title="Using the database" %} diff --git a/docs/pages/docs/Using SQL/custom_queries.md b/docs/pages/docs/Using SQL/custom_queries.md index 846fea04..5d6cbf55 100644 --- a/docs/pages/docs/Using SQL/custom_queries.md +++ b/docs/pages/docs/Using SQL/custom_queries.md @@ -47,11 +47,11 @@ To use this feature, it's helpful to know how Dart tables are named in sql. For override `tableName`, the name in sql will be the `snake_case` of the class name. So a Dart table called `Categories` will be named `categories`, a table called `UserAddressInformation` would be called `user_address_information`. The same rule applies to column getters without an explicit name. -Tables and columns declared in [Drift files]({{ "moor_files.md" | pageUrl }}) will always have the +Tables and columns declared in [Drift files]({{ "drift_files.md" | pageUrl }}) will always have the name you specified. {% endblock %} -You can also use `UPDATE` or `DELETE` statements here. Of course, this feature is also available for +You can also use `UPDATE` or `DELETE` statements here. Of course, this feature is also available for [daos]({{ "../Advanced Features/daos.md" | pageUrl }}), and it perfectly integrates with auto-updating streams by analyzing what tables you're reading from or writing to. @@ -60,7 +60,7 @@ writing to. If you don't want to use the statements with an generated api, you can still send custom queries by calling `customSelect` for a one-time query or `customSelectStream` for a query stream that automatically emits a new set of items when -the underlying data changes. Using the todo example introduced in the +the underlying data changes. Using the todo example introduced in the [getting started guide]({{ "../Getting started/index.md" | pageUrl }}), we can write this query which will load the amount of todo entries in each category: ```dart @@ -90,7 +90,7 @@ Stream> categoriesWithCount() { ``` For custom selects, you should use the `readsFrom` parameter to specify from which tables the query is reading. When using a `Stream`, drift will be able to know after which updates the stream should emit -items. +items. You can also bind SQL variables by using question-mark placeholders and the `variables` parameter: @@ -104,7 +104,7 @@ Stream amountOfTodosInCategory(int id) { } ``` -Of course, you can also use indexed variables (like `?12`) - for more information on them, see +Of course, you can also use indexed variables (like `?12`) - for more information on them, see [the sqlite3 documentation](https://sqlite.org/lang_expr.html#varparam). ## Custom update statements diff --git a/docs/pages/docs/Using SQL/moor_files.md b/docs/pages/docs/Using SQL/drift_files.md similarity index 98% rename from docs/pages/docs/Using SQL/moor_files.md rename to docs/pages/docs/Using SQL/drift_files.md index c9f90ac2..7a6ed7bb 100644 --- a/docs/pages/docs/Using SQL/moor_files.md +++ b/docs/pages/docs/Using SQL/drift_files.md @@ -6,6 +6,8 @@ data: aliases: - /docs/using-sql/custom_tables/ # Redirect from outdated "custom tables" page which has been deleted + - /docs/using-sql/moor_files/ + template: layouts/docs/single --- @@ -174,27 +176,27 @@ CREATE TABLE saved_routes ( id INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL, "from" INTEGER NOT NULL REFERENCES coordinates (id), - to INTEGER NOT NULL REFERENCES coordinates (id) + "to" INTEGER NOT NULL REFERENCES coordinates (id) ); routesWithPoints: SELECT r.id, r.name, f.*, t.* FROM routes r INNER JOIN coordinates f ON f.id = r."from" - INNER JOIN coordinates t ON t.id = r.to; + INNER JOIN coordinates t ON t.id = r."to"; ``` -To match the returned column names while avoiding name clashes in Dart, drift +To match the returned column names while avoiding name clashes in Dart, drift will generate a class having an `id`, `name`, `id1`, `lat`, `long`, `lat1` and a `long1` field. -Of course, that's not helpful at all - was `lat1` coming from `from` or `to` +Of course, that's not helpful at all - was `lat1` coming from `from` or `to` again? Let's rewrite the query, this time using nested results: ```sql routesWithNestedPoints: SELECT r.id, r.name, f.**, t.** FROM routes r INNER JOIN coordinates f ON f.id = r."from" - INNER JOIN coordinates t ON t.id = r.to; + INNER JOIN coordinates t ON t.id = r."to"; ``` -As you can see, we can nest a result simply by using the drift-specific +As you can see, we can nest a result simply by using the drift-specific `table.**` syntax. For this query, drift will generate the following class: ```dart @@ -207,7 +209,7 @@ class RoutesWithNestedPointsResult { } ``` -Great! This class matches our intent much better than the flat result class +Great! This class matches our intent much better than the flat result class from before. At the moment, there are some limitations with this approach: diff --git a/docs/pages/v2.html b/docs/pages/v2.html index 22f04e28..7278c3fe 100644 --- a/docs/pages/v2.html +++ b/docs/pages/v2.html @@ -25,7 +25,7 @@ path: v2 The rewritten compiler is faster than ever, supports more SQL features and gives you more flexibility when writing database code. -[Check the updated documentation]({{ "docs/Using SQL/moor_files.md" | pageUrl }}) +[Check the updated documentation]({{ "docs/Using SQL/drift_files.md" | pageUrl }}) {% endblock %} {% endblock %}