will / crystal-pg

a postgres driver for crystal
BSD 3-Clause "New" or "Revised" License
462 stars 77 forks source link

Fix: statement.connection is a DB::Connection (expected PG::Connection) #276

Closed ysbaddaden closed 10 months ago

ysbaddaden commented 10 months ago

When requiring multiple database drivers (e.g. mysql or sqlite3 in addition to pg), compilation will fail:

In lib/pg/src/pg/result_set.cr:18:51

 18 | @sized_io = Buffer.new(conn.soc, 1, statement.connection)
                                                    ^---------
Error: expected argument #3 to 'PG::ResultSet::Buffer.new' to be PG::Connection, not DB::Connection

As long as we don't require any other DB driver, statement.connection will always be PG::Connection as expected, but when requiring multiple drivers, it will be DB::Connection+. The solution is to make an explicit cast.

will commented 10 months ago

Thanks!