mirror of https://github.com/AMT-Cheif/drift.git
Remove includeJoinedTableColumns entirely
This commit is contained in:
parent
b95e70b438
commit
8d840f3eb3
|
@ -5,8 +5,9 @@
|
|||
It is an error to use a non-nullable type converter on a column that is nullable in
|
||||
SQL and vice-versa.
|
||||
- __Breaking__: Mapping methods on type converters are now called `toSql` and `fromSql`.
|
||||
- __Breaking__: The `includeJoinedTableColumns` parameter on `selectOnly()` is now
|
||||
disabled by default.
|
||||
- __Breaking__: Remove the `includeJoinedTableColumns` parameter on `selectOnly()`.
|
||||
The method now behaves as if that parameter was turned off. To use columns from a
|
||||
joined table, add them with `addColumns`.
|
||||
- Consistently handle transaction errors like a failing `BEGIN` or `COMMIT`
|
||||
across database implementations.
|
||||
- Support nested transactions.
|
||||
|
|
|
@ -571,10 +571,8 @@ class $TodoCategoryItemCountView
|
|||
}
|
||||
|
||||
@override
|
||||
Query? get query => (attachedDatabase.selectOnly(todoCategories,
|
||||
includeJoinedTableColumns: false)
|
||||
..addColumns($columns))
|
||||
.join([
|
||||
Query? get query =>
|
||||
(attachedDatabase.selectOnly(todoCategories)..addColumns($columns)).join([
|
||||
innerJoin(todoItems, todoItems.categoryId.equalsExp(todoCategories.id))
|
||||
]);
|
||||
@override
|
||||
|
@ -686,9 +684,7 @@ class $TodoItemWithCategoryNameViewView extends ViewInfo<
|
|||
|
||||
@override
|
||||
Query? get query =>
|
||||
(attachedDatabase.selectOnly(todoItems, includeJoinedTableColumns: false)
|
||||
..addColumns($columns))
|
||||
.join([
|
||||
(attachedDatabase.selectOnly(todoItems)..addColumns($columns)).join([
|
||||
innerJoin(
|
||||
todoCategories, todoCategories.id.equalsExp(todoItems.categoryId))
|
||||
]);
|
||||
|
|
|
@ -244,13 +244,6 @@ abstract class DatabaseConnectionUser {
|
|||
/// The [distinct] parameter (defaults to false) can be used to remove
|
||||
/// duplicate rows from the result set.
|
||||
///
|
||||
/// The [includeJoinedTableColumns] parameter (defaults to true) can be used
|
||||
/// to determinate join statement's `useColumns` parameter default value. Set
|
||||
/// it to false if you don't want to include joined table columns by default.
|
||||
/// If you leave it on true and don't set `useColumns` parameter to false in
|
||||
/// join declarations, all columns of joined table will be included in query
|
||||
/// by default.
|
||||
///
|
||||
/// For simple queries, use [select].
|
||||
///
|
||||
/// See also:
|
||||
|
@ -258,10 +251,9 @@ abstract class DatabaseConnectionUser {
|
|||
/// - the documentation on [group by](https://drift.simonbinder.eu/docs/advanced-features/joins/#group-by)
|
||||
JoinedSelectStatement<T, R> selectOnly<T extends HasResultSet, R>(
|
||||
ResultSetImplementation<T, R> table,
|
||||
{bool distinct = false,
|
||||
bool includeJoinedTableColumns = false}) {
|
||||
{bool distinct = false}) {
|
||||
return JoinedSelectStatement<T, R>(
|
||||
resolvedEngine, table, [], distinct, false, includeJoinedTableColumns);
|
||||
resolvedEngine, table, [], distinct, false, false);
|
||||
}
|
||||
|
||||
/// Starts a [DeleteStatement] that can be used to delete rows from a table.
|
||||
|
@ -627,11 +619,8 @@ class TableOrViewOperations<Tbl extends HasResultSet, Row> {
|
|||
/// Composes a `SELECT` statement only selecting a subset of columns.
|
||||
///
|
||||
/// This is equivalent to calling [DatabaseConnectionUser.selectOnly].
|
||||
JoinedSelectStatement<Tbl, Row> selectOnly(
|
||||
{bool distinct = false, bool includeJoinedTableColumns = false}) {
|
||||
return _user.selectOnly(_sourceSet,
|
||||
distinct: distinct,
|
||||
includeJoinedTableColumns: includeJoinedTableColumns);
|
||||
JoinedSelectStatement<Tbl, Row> selectOnly({bool distinct = false}) {
|
||||
return _user.selectOnly(_sourceSet, distinct: distinct);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,11 +14,8 @@ extension TableOrViewStatements<Tbl extends HasResultSet, Row>
|
|||
/// Composes a `SELECT` statement only selecting a subset of columns.
|
||||
///
|
||||
/// This is equivalent to calling [DatabaseConnectionUser.selectOnly].
|
||||
JoinedSelectStatement<Tbl, Row> selectOnly(
|
||||
{bool distinct = false, bool includeJoinedTableColumns = false}) {
|
||||
return attachedDatabase.selectOnly(this,
|
||||
distinct: distinct,
|
||||
includeJoinedTableColumns: includeJoinedTableColumns);
|
||||
JoinedSelectStatement<Tbl, Row> selectOnly({bool distinct = false}) {
|
||||
return attachedDatabase.selectOnly(this, distinct: distinct);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -406,8 +406,7 @@ void main() {
|
|||
final categories = db.categories;
|
||||
final todos = db.todosTable;
|
||||
|
||||
final query =
|
||||
db.selectOnly(categories, includeJoinedTableColumns: false).join([
|
||||
final query = db.selectOnly(categories).join([
|
||||
innerJoin(
|
||||
todos,
|
||||
todos.category.equalsExp(categories.id),
|
||||
|
|
|
@ -1497,8 +1497,7 @@ class $CategoryTodoCountViewView
|
|||
|
||||
@override
|
||||
Query? get query =>
|
||||
(attachedDatabase.selectOnly(categories, includeJoinedTableColumns: false)
|
||||
..addColumns($columns))
|
||||
(attachedDatabase.selectOnly(categories)..addColumns($columns))
|
||||
.join([innerJoin(todos, todos.category.equalsExp(categories.id))])
|
||||
..groupBy([categories.id]);
|
||||
@override
|
||||
|
@ -1605,9 +1604,7 @@ class $TodoWithCategoryViewView
|
|||
}
|
||||
|
||||
@override
|
||||
Query? get query => (attachedDatabase.selectOnly(todos,
|
||||
includeJoinedTableColumns: false)
|
||||
..addColumns($columns))
|
||||
Query? get query => (attachedDatabase.selectOnly(todos)..addColumns($columns))
|
||||
.join([innerJoin(categories, categories.id.equalsExp(todos.category))]);
|
||||
@override
|
||||
Set<String> get readTables => const {'todos', 'categories'};
|
||||
|
|
|
@ -132,8 +132,8 @@ class ViewWriter extends TableOrViewWriter {
|
|||
buffer.write('@override\nQuery? get query => ');
|
||||
final query = view.viewQuery;
|
||||
if (query != null) {
|
||||
buffer.write('(attachedDatabase.selectOnly(${query.from}, '
|
||||
'includeJoinedTableColumns: false)..addColumns(\$columns))'
|
||||
buffer.write('(attachedDatabase.selectOnly(${query.from})'
|
||||
'..addColumns(\$columns))'
|
||||
'${query.query};');
|
||||
} else {
|
||||
buffer.write('null;\n');
|
||||
|
|
Loading…
Reference in New Issue