pgtyped
pgtyped copied to clipboard
Error: Postgres type 'geometry' is not supported by mapping
Is there a way to declare mappings anywhere?
Currently my geometry typed is showing as never
. Would it make sense to type is as unknown?
Love the idea behind this lib!
I see in the @pg-typed/cli
there is a concept of overrides
but I don't see it used anywhere.
Would adding our own types for plugin/non-standard columns be sufficient? i.e.
- add a field to the config to point to a js file that exports a map of our types
- in the config package, import the file and the override mapping
- import the overrides and combine them with the DefaultTypeMapping in https://github.com/adelsz/pgtyped/blob/master/packages/cli/src/types.ts
I'm not totally sure how your been testing the package, a short Contributing.md
would be really helpful :)
@goofiw Encountered this recently. Should be pretty easy to type as Array<Array<Array<Array<number>>>>
which we've done in the past.
Hi @goofiw,
Type overrides weren't ever completely implemented. As you noticed, the core TypeAllocation data structures do support overrides and external file imports, but all of that functionality isn't exposed in the config. There was also some discussion on that here https://github.com/adelsz/pgtyped/issues/60.
I think the only missing piece at this point is adding an imported types field to the config and connecting that to the type allocator/mapper. A good example of the config structure would be this:
{
"transforms": [ ... ],
"types": {
"int:": {
"name": "WholeNumber",
"from": "./my-pkg/whole-number"
},
"bytea": {
"name": "Uint8Array"
},
"shipping_status": {
"name": "ShippingStatus",
"enumValues": ["Shipped", "Pending"]
}
},
}
Alternatively, if you only need the geometry
type then I would suggest to follow @nickreese suggestion here and contribute it directly to types.ts
.
@adelsz Thanks for responding!
I was thinking a path to an pgtyped.overrides.ts file might be more extendable - I'm doing some geometry functions as well that would be cool to define types for.
Whats your method for testing? Can I help put those in a contributing.md?
I was thinking a path to an pgtyped.overrides.ts file might be more extendable - I'm doing some geometry functions as well that would be cool to define types for.
Got it, adding overrides is the way to go then.
Whats your method for testing? Can I help put those in a contributing.md?
We have both integration and unit tests, with the whole flow defined in the github hook. Note that running the integration tests requires Docker. Essentially, you can test everything in four steps:
-
npm ci
-
npx lerna bootstrap && npm run build
-
npm test
-
npm run test:integration
a short Contributing.md would be really helpful :)
You are right, a contributing.md
is long overdue from my side. I will try to draft one soon, but will also gladly merge a first basic version if someone can contribute it sooner.
@adelsz Awesome - 2 quick last things:
-
Do you have any advice for pulling a column type that might be added by a plugin (like PostGis). I'm having trouble thinking of a good way to test it besides making a second docker-compose that uses a PostGis Postgres database but I'm not sure you want that much overhead.
-
I think I'll just go the 'config' route - I didn't realize the functions I was planning on using type themselves by just passing arguments.
@goofiw Have you made any progress on this? I'm in a similar position - would really like to use this library but our database has Postgis installed so I need support for Point
and other geometry columns. Happy to help implement if there's anything I can do! Thanks :)
Looking for a review / merge on my PR above if anyone is able to take a look! thanks in advance
Type overrides have been merged.