mirror of https://github.com/AMT-Cheif/drift.git
Fix missing quotes in drift files docs
This commit is contained in:
parent
6efe6de3ba
commit
573bd20eb8
|
@ -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.
|
||||
|
|
|
@ -149,7 +149,7 @@ Let's take a look at what drift generated during the build:
|
|||
- a `Selectable<Todo> 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<List<Todo>>`)
|
||||
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" %}
|
||||
|
|
|
@ -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<List<CategoryWithCount>> 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<int> 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
|
||||
|
|
|
@ -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:
|
|
@ -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 %}
|
||||
|
||||
|
|
Loading…
Reference in New Issue