canonical / sqlair

Friendly type mapping for SQL databases
Apache License 2.0
17 stars 9 forks source link

Fix missing named input parameters and add complete error checks #43

Closed Aflynn50 closed 1 year ago

Aflynn50 commented 1 year ago

This PR fixes a few issues that were found with complete when writing PR #42.

The first issue is that we were still using ? in the query but in complete were generating named parameters of the form @sqlair_0. We use named parameters to avoid issues with users add their own ? to the query and displacing the parameters passed to the DB.

The second issue is that the error messages thrown when a user passes a pointer to a struct instead of a copy the error message was confusing. I found this issue when I made that mistake. Similarly if they passed a none struct type. Both of these problems have now been fixed with explicit checks of the Kind that throw the appropriate errors.

The error tests for Complete in expr_test.go have also been refactored into a table driven format.