oguimbal / pg-mem

An in memory postgres DB instance for your unit tests
MIT License
1.89k stars 94 forks source link

Fix AST coverage check error #389

Open zookatron opened 4 months ago

zookatron commented 4 months ago

Currently when you run a query against pg-mem with fully qualified column names like SELECT "public"."test"."val" FROM "public"."test", it gives you an AST coverage error like The query you ran generated an AST which parts have not been read by the query planner. This means that those parts could be ignored: ⇨ .columns[0].expr.table.name ("test"). This is happening because when the query planner retrieves the column data, in some cases it never actually checks the statement table name to be sure it matches before returning the column description. This commit refactors the column retrieval code to ensure this always gets checked.

I'm not familiar enough with the internal logic of this library to know if this fix is the "correct' way of doing this so I would like feedback on whether or not there is a better solution. But this logic fix makes sense to me so I figured I would start with a PR.

I believe this should fix this old bug as well: https://github.com/oguimbal/pg-mem/issues/130