Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile-time error in generated [for View] DataClass #3454

Closed
MichaelDark opened this issue Feb 6, 2025 · 4 comments
Closed

Compile-time error in generated [for View] DataClass #3454

MichaelDark opened this issue Feb 6, 2025 · 4 comments

Comments

@MichaelDark
Copy link
Contributor

MichaelDark commented Feb 6, 2025

Data Class generated from a View using dart run drift_dev schema generate starts with $, therefore creating a compile-time error.

Simplest fix would be to wrap className with ${...}:

-   ..write("return (StringBuffer('$className(')");
+   ..write("return (StringBuffer('\${$className}(')");
// Assuming `class $ClassName extends DataClass implements Insertable<$ClassName>`
-   return (StringBuffer('$ClassName(') // ERROR: Undefined name 'ClassName'.
+   return (StringBuffer('${$ClassName}(')

Repro:

  • create Dart-defined View
  • dump schema
  • generate schema

Reference:

..write("return (StringBuffer('$className(')");

@MichaelDark
Copy link
Contributor Author

@simolus3 View entityInfoName is prefixed with $, therefore this DataClass has $ prefix only in the schema dump.

Reference:

entityInfoName: '\$${discovered.dartElement.name}View',

@simolus3
Copy link
Owner

simolus3 commented Feb 6, 2025

Good catch, thanks for the report!

@MichaelDark
Copy link
Contributor Author

@simolus3 Thank you very much for a quick fix!
Is the next release already planned for a specific date/week, or it is still a "work in progress"?

@simolus3
Copy link
Owner

simolus3 commented Feb 8, 2025

I've just released drift_dev version 2.25.0 which contains this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants