tokio-rs / rdbc

Rust DataBase Connectivity (RDBC) :: Common Rust API for database drivers
Apache License 2.0
569 stars 25 forks source link

Decide on 0-based versus 1-based indexes #22

Closed andygrove closed 4 years ago

andygrove commented 4 years ago

So far I've been mimicking ODBC/JDBC in using 1-based indexes in ResultSet and ResultSetMetaData.

I did this to ease the translation of existing ODBC/JDBC code but it feels dirty.

Realistically we will want idiomatic Rust ways of accessing this API using iterators so maybe this low-level API can remain ugly ... I am interested to hear what others think.

mamcx commented 4 years ago

I think is better to stick to the idioms of each lang. In rust 0-based is the norm. Also, in rust is ok to do imperative style, not only depending in functional idioms like iterators.

rumatoest commented 4 years ago

In JDBC indexes for prepare statements started from 1. And it case me a lot of pain. But probably there was some reasoning about it - in SQL you can address columns by indexes, for example select name, status from info order by 1 would order by id column.

I think that 0 based index is right choice, because you want to address array index from prepared statement and there should be no confusions.

andygrove commented 4 years ago

Thanks. I agree. Fixed in https://github.com/andygrove/rdbc/pull/30