Closed Allam76 closed 2 years ago
@Allam76 PRs are always welcome!
The InformationSchema
(IS) reader is independent from the postgres.metaReader
. The fact that the postgres.metaReader
uses parts of the IS reader is an implementation detail. We might remove that some day, and instead read the information directly from PostgreSQL's system catalogs, as we already do for some reader sub-interfaces. You can't pass the IS reader options to the postgres.metaReader
.
The postgres.metaReader
also is not meant to be extended. If you want to change its behavior, create a new reader. Feel free to copy the code from the postgres reader.
An alternative is to allow postgres.metaReader
to receive a similar option to configure the data type formatter, but there would need to be a use case for it in usql
itself. Right now, even if it's reused for multiple different databases compatible with PostgreSQL (like CockroachDB), it configures itself.
Why do you need to change the data type formatter in the first place?
Or use the metadata.NewPluginReader()
to override only the Columns()
method in the postgres reader.
Consider the following code:
Here I would like to add a custom data type formatter to the postgres metadata reader. This fails with:
panic: interface conversion: metadata.Reader is *metadata.LoggingReader, not *informationschema.InformationSchema
From reading the offending code:
it is clear that the
opts...
are assigned twice. Last time to an incompatible reader (LoggingReader).Maybe also consider putting
in uppercase to facilitate extension.