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
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
The sql operator's mapWith method lets us specify mappers for decoding from the database, but there are use cases where we need to encode. See the example below.
// Example A: works greateq(myTable.myDecimalCol,newDecimal("0"))// Example B: driver error: invalid input syntax for type numeric: ""0""eq(sql`abs(${myTable.myDecimalCol})`,newDecimal("0"))// Example C: works, but not ideal imoeq(sql`abs(${myTable.myDecimalCol})`,newDecimal("0").toString())
The issue in example B appears to be that it's not using the custom type's toDriver function, which is reasonable. However, there's no way to make it use it.
This would be useful in functions that apply a SQL operator to a column value, but don't change its resultant type, e.g. it would be very useful to be able to write a function like this where the column's mapFromDriverValueandmapToDriverValue are applied:
Feature hasn't been suggested before.
Describe the enhancement you want to request
The sql operator's
mapWith
method lets us specify mappers for decoding from the database, but there are use cases where we need to encode. See the example below.decimalType
custom typeThe issue in example B appears to be that it's not using the custom type's
toDriver
function, which is reasonable. However, there's no way to make it use it.This would be useful in functions that apply a SQL operator to a column value, but don't change its resultant type, e.g. it would be very useful to be able to write a function like this where the column's
mapFromDriverValue
andmapToDriverValue
are applied:LMK if I'm missing something! Thanks!
The text was updated successfully, but these errors were encountered: