georgysavva / scany

Library for scanning data from a database into Go structs and more
MIT License
1.24k stars 67 forks source link

Add test case for nullable nested anonymous #46

Closed idaunis closed 1 year ago

georgysavva commented 3 years ago

I played around with this test and how it behaves with your recent changes in the pgtype library. I don't quite see what we want to show with this test for the dbscan package and scany library as a whole. dbscan package works with abstract rows and should not depend and assert some specific library implementation details.

  1. First of all, if we run that test for the pgx library it passes only because CustomString is made of primitive type string and you can remove the .Scan() method implementation and it will still pass.
  2. For SQL library on the other hand, without .Scan() implementation it will fail, because they don't do struct unwrapping as you implemented in the recent pgtype patch.
  3. If you implement the CustomString as a struct:
    type CustomString struct {
    s string
    }

    The test will still fail for the pgx library even with the recent pgtype version.

I think we should wait until https://github.com/jackc/pgx/issues/1000 is addressed and then implement a general test that would work for both libraries.

In the meantime, I added a similar test to yours to pgxscan and sqlscan tests since they are specific for each library: https://github.com/georgysavva/scany/pull/50

georgysavva commented 1 year ago

Closing due to inactvity. Feel free to reopen.