Open chani22 opened 1 week ago
Thanks for the report! Unfortunately I can't reproduce this locally by pasting the table code alone (it generates the same code but I don't get the error about column
having an invalid type). I don't think this is an analyzer problem either since the same thing is happening when compiling the app.
If you hover over a composableBuilder
invocation in VS Code, what does the popup say its type is? It should be something like ColumnFilters<String> Function({required ColumnFilters<String> Function(GeneratedColumn<String>, Set<JoinBuilder>) builder, required GeneratedColumn<String> column})
, but I suspect there may be something going wrong here.
As an interim workaround, you can disable generating the code causing this error by creating builder options with this content:
targets:
$default:
builders:
drift_dev:
options:
generate_manager: false
But obviously we want to know what's happening here so that you can keep that code. also cc @dickermoshe (not urgent though).
I’ll take a look, but if it not reproducible, there isn’t much I can do…
On Tue, Jun 11, 2024 at 10:42 AM Simon Binder @.***> wrote:
Thanks for the report! Unfortunately I can't reproduce this locally by pasting the table code alone (it generates the same code but I don't get the error about column having an invalid type). I don't think this is an analyzer problem either since the same thing is happening when compiling the app. If you hover over a composableBuilder invocation in VS Code, what does the popup say its type is? It should be something like ColumnFilters
Function({required ColumnFilters Function(GeneratedColumn , Set ) builder, required GeneratedColumn column}), but I suspect there may be something going wrong here. As an interim workaround, you can disable generating the code causing this error by creating builder options https://drift.simonbinder.eu/docs/advanced-features/builder_options/ with this content:
targets: $default: builders: drift_dev: options: generate_manager: false
But obviously we want to know what's happening here so that you can keep that code. also cc @dickermoshe https://github.com/dickermoshe (not urgent though).
— Reply to this email directly, view it on GitHub https://github.com/simolus3/drift/issues/3043#issuecomment-2160943504, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASDJ6236LK3XH4LO2RO6E4DZG4EFJAVCNFSM6AAAAABJD4SXIOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRQHE2DGNJQGQ . You are receiving this because you were mentioned.Message ID: @.***>
@simolus3 The temporary workaround you provided works effectively. Thank you very much.
And, I agree that we need to find a fundamental solution.
I have attached the popup that appears when hovering over composableBuilder
via vscode.
I am ready to provide any additional information needed to resolve this issue. Please let me know if there is anything else you need.
@chani22 I need the database class too
You've only posted the table class
@chani22 This is still working fine by me.
Do you have any build.yaml
file that has some other settings?
What's your output of flutter doctor
?
Did you try building with dart run build_runner build --delete-conflicting-outputs
?
What about a flutter clean
?
@dickermoshe There was no build.yaml file before simolus3 provided the temporary workaround.
This is output of flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.1, on macOS 14.5 23F79 darwin-arm64, locale ko-KR)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] VS Code (version 1.81.1)
[✓] Connected device (5 available)
[✓] Network resources
• No issues found!
I have tried both dart run build_runner build --delete-conflicting-outputs
and flutter clean
multiple times, and I just tried both methods again, but I still confirmed that the error code exists in the database.g.dart file.
What about dart info
?
Here is output of dart info
If providing this information as part of reporting a bug, please review the information
below to ensure it only contains things you're comfortable posting publicly.
#### General info
- Dart 3.4.1 (stable) (Tue May 21 15:46:25 2024 +0000) on "macos_arm64"
- on macos / Version 14.5 (Build 23F79)
- locale is ko-KR
#### Project info
- sdk constraint: '>=2.17.0 <=3.4.1'
- dependencies: animated_check, awesome_notifications, badges, change_app_package_name, cloud_firestore, conditional_parent_widget, convex_bottom_bar, cupertino_icons, data_table_2, device_info_plus, dotted_border, drift, dropdown_button2, firebase_analytics, firebase_core, firebase_crashlytics, firebase_messaging, firebase_remote_config, flutter, flutter_bounceable, flutter_cupertino_date_picker_fork, flutter_easyloading, flutter_inappwebview, flutter_inset_box_shadow, flutter_local_notifications, flutter_material_pickers, flutter_native_splash, flutter_screen_lock, flutter_sticky_header, flutter_svg, flutter_swiper_null_safety, flutter_toggle_tab, flutter_typeahead, fluttertoast, font_awesome_flutter, get, getwidget, glassmorphism, group_button, hexcolor, http, internet_connection_checker, intl, is_first_run, jwt_decode, kakao_flutter_sdk, kpostal, linked_scroll_controller, logger, lottie, modal_side_sheet, multi_select_flutter, mutex, notification_permissions, package_info_plus, path, path_provider, percent_indicator, rect_getter, shared_preferences, shimmer, show_up_animation, sign_in_with_apple, smooth_page_indicator, sqlite3_flutter_libs, sticky_headers, store_redirect, styled_widget, substring_highlight, table_calendar, transparent_pointer, url_launcher, watcher, webview_flutter, word_break_text
- dev_dependencies: build_runner, drift_dev, flutter_launcher_icons, flutter_lints, flutter_oss_licenses, flutter_test
- elided dependencies: 1
#### Process info
| Memory | CPU | Elapsed time | Command line |
| -----: | ---: | -----------: | ------------------------------------------------------------------------------- |
| 1 MB | 0.0% | 04-01:43:48 | dart devtools --machine --allow-embedding --dtd-uri ws:<path>/fZvSUgQ0B7I3fiaD |
| 1 MB | 0.0% | 04-01:24:19 | dart devtools --machine --allow-embedding --dtd-uri ws:<path>/pB0ZQGL0dkj0ctw3 |
| 6 MB | 0.0% | 04-01:43:48 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.90.0 |
| 6 MB | 0.0% | 04-01:24:19 | dart language-server --protocol=lsp --client-id=VS-Code --client-version=3.90.0 |
| 1 MB | 0.0% | 04-01:43:48 | dart tooling-daemon --machine |
| 1 MB | 0.0% | 04-01:24:19 | dart tooling-daemon --machine |
| 4 MB | 0.0% | 04-01:24:19 | flutter_tools.snapshot daemon
Hmmm, this is really strange. I've got the same with no issues.
What does hovering over $state.table.id
reveal?
By me:
Can you post the generated code? You can email it to me privately if you feel more comfortable dickermoshe@gmail.com
Same type hovering over on $state.table.id
@dickermoshe I just sent the full code of the database.g.dart file to the email you provided. Thank you for your consideration.
That is a fairly nasty bug.
The generics on composableBuilder
state that the column provided is passed into the builder.
@simolus3 This seems like a dart bug.
@chani22
What about hovering over column
in builder: (column, joinBuilders) =>
?
@chani22 Your generated code matches mine.
Here is what appears when hovering over the column
.
This is really odd. If this a bug in dart, the next steps will be long and painful. I want to make sure that we aren't the problem. I'll get back to you
I sincerely appreciate your prompt response. I will proceed with the development using the temporary workaround you provided. We will address the issue again once the bug is resolved.
Thank you once again.
Just to be sure - this also prevents the code from running? I've sometimes seen issues where the analyzer reports phantom type errors but the front end gets it right. That's definitely an analyzer bug, but if the compiler also refuses to run the code with the same reason, chances are we're misusing generics in a subtle way (but then it's weird that it only fails here).
One possible approach to diagnose this further could be to make the generated code more verbose (it could spell out the generics in the composableBuilder
invocation or add explicit types to the function expression passed to builder
).
@chani22
Try replacing this on BuildingTableTableFilterComposer
ColumnFilters<int> get id => $state.composableBuilder(
column: $state.table.id,
builder: (column, joinBuilders) =>
ColumnFilters(column, joinBuilders: joinBuilders));
with this:
ColumnFilters<int> get id => $state.composableBuilder<ColumnFilters<int>,GeneratedColumn<int>>(
column: $state.table.id,
builder: (column, joinBuilders) =>
ColumnFilters(column, joinBuilders: joinBuilders));
I've added the generics explicitly, maybe that will help?
@simolus3 Yeah, it breaks on flutter run as stated in the initial bug report
If I ignore the above error and run flutter run, I encounter the following build-time error.
Error (Xcode): lib/data/database/database.g.dart:7976:25: Error: The argument type 'Object?' can't be assigned to the parameter type 'Expression
'.
Hello,
I am encountering an issue with the generated code from Drift. When I run the code generation using
build_runner
, I receive the following error by my ide(vscode):If I ignore the above error and run flutter run, I encounter the following build-time error.
Below is the screen of error message reported by VSCode.
Here is a part of the
database.dart
code I wrote, defining the BuildingTable.Below is a part of the yaml file defining the related dependencies.
How can I resolve this issue?