canonical / sqlair

Friendly type mapping for SQL databases
Apache License 2.0
16 stars 8 forks source link

Include raw expression in `Query` errors #107

Closed Aflynn50 closed 5 months ago

Aflynn50 commented 9 months ago

Add information to errors in query.go about the expression in the query that the error pertains to. Extra information is also added to the error that reports duplicate type members in the query, it now includes the expressions in which the two instances occur.

In the PreparedExpr a list of typeMembers was used to store the query input and outputs . This is replaced by a list of typeLocations. The typeLocation struct contains the typeMember and the raw string. typeMember structs are reused across statements so it would be strange to include information specific to the statement inside them. The typeLocation struct can also be used in the future to retain other contextual information about where the typeMember occurs in the query.

Aflynn50 commented 9 months ago

Note that this PR is affected by the bug fixed in #98.

letFunny commented 8 months ago

Now that we are changing the pipeline we should hold this PR. We would not be needing typeLocation, only to embed the raw string in the tree replacing PreparedExpr.