stablekernel / postgresql-dart

Dart PostgreSQL driver: supports extended query format, binary protocol and statement reuse.
https://www.dartdocs.org/documentation/postgres/latest
BSD 3-Clause "New" or "Revised" License
129 stars 32 forks source link

[Enhancement] Add support for additonal types which are created via extensions e.g Geospatial objects. #139

Closed bettdouglas closed 2 years ago

bettdouglas commented 4 years ago

This request is in accordance to https://github.com/stablekernel/postgresql-dart/pull/130#discussion_r437470041. After doing some searching, types created by CREATE EXTENSION extension_name are dynamic and are not static unlike datatypes fully supported by postgres. The only way to get their type_id and typeString is to query the pg_types table in postgres.

This will enable people to extend the library easily once they have a way of decoding and encoding the data types from dart objects to pg_type as well as from the types in postgres to dart objects.

This change will enable adding extra types from

Adding a new type:

  1. add item to this enumeration
  2. update all switch statements on this type
  3. add pg type code -> enumeration item in PostgresBinaryDecoder.typeMap (lookup type code: https://doxygen.postgresql.org/include_2catalog_2pg__type_8h_source.html)
  4. add identifying key to PostgreSQLFormatIdentifier.typeStringToCodeMap.

to

Adding a new type:

  1. add item to this enumeration
  2. update all switch statements on this type
  3. add identifying key to PostgreSQLFormatIdentifier.typeStringToCodeMap.
  4. Add decoders and encoders for this new data type

If PR is accepted, support for geospatial objects using extension https://postgis.net and queries is already using this feature is implemented with some tests on this branch https://github.com/bettdouglas/postgresql-dart/tree/geospatial-support which closes https://github.com/stablekernel/aqueduct/issues/747 https://github.com/stablekernel/aqueduct/issues/634 https://github.com/stablekernel/postgresql-dart/issues/120

The query_reuse_test.dart is failing though. I may need help fixing that.

bettdouglas commented 4 years ago

On my local machine, on my local postgres 12, all checks are passing but on Travis which is 9.6, some checks are not passing

bettdouglas commented 4 years ago

After testing with a docker image in 9.6, all checks are passing. I'm not sure why the tests are failing on Travis

bettdouglas commented 4 years ago

@isoos @stablekernel-admin @joeconwaystk can anyone kindly review this and give some feedback?

isoos commented 2 years ago

@bettdouglas: the package's main repository is now at https://github.com/isoos/postgresql-dart I'm not sure if this PR is still easy to port, as it has diverged a bit...

bettdouglas commented 2 years ago

I think its the PR is too outdated. I'll just close it and try something fresh from the new repository.

I was browsing through old projects and when merging upstream changes(null safety), it pushed & pulled upstream changes.