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
With the introduction of type converters, the bridge between Expressions and EdgeQL starts to bend. Currently, the querybuilder correctly translates assignment/initializations expressions and shapes, but it falls short at expressions that are directly influenced by type converted properties.
The expression x => x.SnowflakeId == targetId does not take into account that SnowflakeId is actually a string in EdgeDB, and treats targetId as a number, producing the following snippet:
.snowflake_id =<int64>$random_var_name
which errors due to the type difference of str and int64.
Potential solution
We can look to quantum mechanics for a solution, taking inspiration from the principle of entanglement. The query builder can find all expressions entangled with a particular type converted property and put the entangled references thru the same type converter to build the EdgeQL query.
With this approach, our above expression follows this logic:
Binary expression is translated
The member expression x.SnowflakeId is discovered as a type converted property.
The expression tree is walked backwards from the MemberExpression and any values with the same shared type as the member expression are updated with the converted value.
I believe that a ExpressionVisitor can be used to achieve this, if not we can simply just rebuild the effected expressions.
The text was updated successfully, but these errors were encountered:
Summary
With the introduction of type converters, the bridge between Expressions and EdgeQL starts to bend. Currently, the querybuilder correctly translates assignment/initializations expressions and shapes, but it falls short at expressions that are directly influenced by type converted properties.
Example:
The expression
x => x.SnowflakeId == targetId
does not take into account thatSnowflakeId
is actually astring
in EdgeDB, and treatstargetId
as a number, producing the following snippet:which errors due to the type difference of
str
andint64
.Potential solution
We can look to quantum mechanics for a solution, taking inspiration from the principle of entanglement. The query builder can find all expressions entangled with a particular type converted property and put the entangled references thru the same type converter to build the EdgeQL query.
With this approach, our above expression follows this logic:
x.SnowflakeId
is discovered as a type converted property.I believe that a ExpressionVisitor can be used to achieve this, if not we can simply just rebuild the effected expressions.
The text was updated successfully, but these errors were encountered: