floor icon indicating copy to clipboard operation
floor copied to clipboard

Generating duplicated definitions with @transaction

Open balenaultra opened this issue 1 year ago • 3 comments

After updating my project and running the build_runner i got an error in database.g.dart on my insert commands with the @transaction annotation.

I don't know if is a bug or just my misunderstood by using this property

My DAO

@dao
abstract class CartDAO {
  @insert
  @transaction
  Future<int> insertCart(DatabaseCart cart);
}

generated database file.

@override
  Future<int> insertCart(DatabaseCart cart) {
    return _databaseCartInsertionAdapter.insertAndReturnId(
        cart, OnConflictStrategy.abort);
  }

  @override
  Future<int> insertCart(DatabaseCart cart) async {
    if (database is sqflite.Transaction) {
      return super.insertCart(cart);
    } else {
      return (database as sqflite.Database)
          .transaction<int>((transaction) async {
        final transactionDatabase = _$AppDatabase(changeListener)
          ..database = transaction;
        return transactionDatabase.cartDAO.insertCart(cart);
      });
    }
  }

problem

The name 'insertCart' is already defined.
Try renaming one of the declarations.

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.7, on macOS 13.2.1 22D68 darwin-x64, locale en-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.76.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

My example project. flutter_floor_bug.zip

balenaultra avatar Mar 15 '23 12:03 balenaultra