alaisi / postgres-async-driver

Asynchronous PostgreSQL Java driver
Apache License 2.0
287 stars 38 forks source link

Data access by field index is broken in PgRow. #31

Open daemas opened 7 years ago

daemas commented 7 years ago

PgRow's get***(int index) methods are broken because the order of columns is messed up in PgRow.columns and PgRow.pgColumns.

daemas commented 7 years ago

It worked for me in version 0.6, but after upgrading to a newer version it stopped working. I think this happened because of the replacement of LinkedHashMap with a HashMap in PgConnection class to store information about columns. LinkedHashMap guarantees the order of the inserted elements, while HashMap does not, according to Java specification.

RyanHoldren commented 7 years ago

I can confirm @daemas findings. I was indeed able to fix this issue by changing the HashMap back to a LinkedHashMap in PgConnection.getColumns().

RyanHoldren commented 7 years ago

https://github.com/alaisi/postgres-async-driver/pull/51