You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we are currently working on migrating an app to the newest drift version, coming from 1.x.
This works fine after upgrading for most queries, but we get an error when using a custom expression within the SELECT statement. The error while generating is Null check operator used on a null value.
We are mainly doing this to reuse the expression (and some code) in multiple queries and drift files.
Is it not possible anymore to use custom expression in SELECT statements?
If not, are there better alternatives than calling the custom functions directly in drift files? Doing that shows a warning ( Function calcStatus could not be found), but the generated code looks okay.
Example
Simplified example of our queries and how it worked before upgrading and the full error that occurs now:
Query:
exampleQuery as Example:
SELECT CAST($status AS INT) AS status FROM examples;
Generated code:
Selectable<Example> exampleQuery(
Expression status) {
final generatedstatus = $write(status, hasMultipleTables: true);
return customSelect(
'SELECT CAST(${generatedstatus.sql} AS INT) AS status',
variables: [
...generatedstatus.introducedVariables,
],
readsFrom: {
examples,
...generatedstatus.watchedTables,
}).map((QueryRow row) {
return Example
status: row.read<int>('status'),
);
});
}
}
Hey, still a big fan of your library!
we are currently working on migrating an app to the newest drift version, coming from 1.x.
This works fine after upgrading for most queries, but we get an error when using a custom expression within the SELECT statement. The error while generating is
Null check operator used on a null value
.We are mainly doing this to reuse the expression (and some code) in multiple queries and drift files.
Is it not possible anymore to use custom expression in SELECT statements?
If not, are there better alternatives than calling the custom functions directly in drift files? Doing that shows a warning (
Function calcStatus could not be found
), but the generated code looks okay.Example
Simplified example of our queries and how it worked before upgrading and the full error that occurs now:
Query:
Generated code:
Caller:
calcStatus is a custom function added to sql by calling
database.createFunction(functionName: "calcStatus", ...)
The full error:
Error:
The text was updated successfully, but these errors were encountered: