edgedb / edgedb-rust

The official Rust binding for EdgeDB
https://edgedb.com
Apache License 2.0
214 stars 26 forks source link

Use less strict (compatable) int types for encoding #324

Closed MrFoxPro closed 5 months ago

MrFoxPro commented 5 months ago

Rust by default uses i32 for integers, so, for arguments (especially useful for named) I think we can allow passing i32 as i64, as cast from one to another should be safe.

MrFoxPro commented 5 months ago

I also would like to add some debug logs here so user aware for this cast, but as I see edgedb-rsut doesn't produce any logs now, there is no tracing

MrFoxPro commented 5 months ago

on rust nighlty build is successful, interesting

aljazerzen commented 5 months ago

This makes sense, because we are not wasting any space: if the query requires int64, we will be sending 64 bits and rejecting the argument only means that the user must correct the argument and gain basically nothing from it.

I'll expand this approach to all types for which this also makes sense.

MrFoxPro commented 5 months ago

This makes sense, because we are not wasting any space: if the query requires int64, we will be sending 64 bits and rejecting the argument only means that the user must correct the argument and gain basically nothing from it.

I'll expand this approach to all types for which this also makes sense.

I'm not sure about float casting though

aljazerzen commented 5 months ago

What would be your reason against? As far as I know, all values of f32 are also expressible in f64. So there would never be any change to the semantic value of the float.

MrFoxPro commented 5 months ago

What would be your reason against? As far as I know, all values of f32 are also expressible in f64. So there would never be any change to the semantic value of the float.

okay