drift fix
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
This commit is contained in:
parent
a4c33e99bf
commit
0914a62d35
1 changed files with 10 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:drift/drift.dart';
|
||||
import 'package:drift_postgres/drift_postgres.dart';
|
||||
import 'package:mnemo_cards_backend/database/database.dart';
|
||||
|
||||
/// Миксин для добавления soft delete функциональности в DAO
|
||||
|
|
@ -34,8 +35,15 @@ mixin SoftDeleteMixin<T extends Table, D> on DatabaseAccessor<AppDatabase> {
|
|||
SimpleSelectStatement<T, D> selectActive() {
|
||||
return select(table)
|
||||
..where((t) {
|
||||
final isDeletedColumn = (t as dynamic).isDeleted;
|
||||
return isDeletedColumn.equals(false);
|
||||
// Проблема: через dynamic Drift может неправильно определить тип boolean
|
||||
// и сгенерировать SQL, который сравнивает boolean с integer
|
||||
// Решение: используем прямое SQL выражение для правильного сравнения boolean
|
||||
// В PostgreSQL имена колонок в snake_case: is_deleted
|
||||
final tableName = table.actualTableName;
|
||||
return CustomExpression<bool>(
|
||||
'"$tableName"."is_deleted" = FALSE',
|
||||
precedence: Precedence.comparison,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue