Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres Support #28

Closed
ArsenyYankovsky opened this issue Mar 3, 2020 · 12 comments
Closed

Postgres Support #28

ArsenyYankovsky opened this issue Mar 3, 2020 · 12 comments

Comments

@ArsenyYankovsky
Copy link
Owner

I've started working on a Postgres support for the driver. I managed to get basic queries to work, but most of the tests fail currently. Currently the issue is the date string conversion. I've created a thread on AWS forums here.

I will push the branch later.

I also found that the cold start is much better with Postgres (under 10 seconds) and it doesn't throw an error.

@idhard
Copy link

idhard commented Mar 3, 2020

I think you will not be able to support PotgreSQL until this is solved

@ArsenyYankovsky
Copy link
Owner Author

I saw that one and wanted to see how far I can go without hitting that wall. Seems like I'm facing the issue number 2.

Not sure if it could be solved that easily, but I can try to get the types since the driver is specifically written for the ORM.

I'm going to make the code look nicer and setup CI. Give me a couple of days and I'll push the work on progress branch so we can collaborate on that.

@ArsenyYankovsky
Copy link
Owner Author

ArsenyYankovsky commented Mar 9, 2020

I pushed my changes into the postgres branch. I also created a PR in the TypeORM repo here.

The postgres driver is currently in a POC state. To fix dates/timestamps in queries I added type hints. All the basic functional tests are working with the postgres version of a driver, but I'm sure there are some cases I haven't accounted for.

Please let me know if you know find any cases that aren't working and are critical, I'll try to fix them before I release a new version of a driver. Otherwise I'll release it once the TypeORM PR gets merged.

@filipsuk
Copy link

@ArsenyYankovsky I would like to test this for you. How do I install this version as it is not merged yet? tried npm install ArsenyYankovsky/typeorm#data-api-pg without any luck

@ArsenyYankovsky
Copy link
Owner Author

@filipsuk Please take a look at how it's done on the CI in the .circleci file. Basically, you'll need to checkout and build the typeorm and link it to your project.

@nathanagez
Copy link

Hi @ArsenyYankovsky, I would love to contribute to this project and help you ! What can I do ?

@ArsenyYankovsky
Copy link
Owner Author

@nathanagez Thank you, currently the postgres support is released in version 1.3.0 of the driver. The PR in the TypeORM repo was merged, but it's yet to be released.
If you could test the TypeORM master version and 1.3.0 driver in more use cases so we can find bugs earlier that would be perfect.

In general, it would also be nice to run tests against local-data-api instead of a database in my account.

@ArsenyYankovsky
Copy link
Owner Author

I'm happy to announce that Postgres support was released with the latest TypeORM release (0.2.25).
I haven't tested it beyond the tests in this project though, so please report anything that's not working for you.

@filipsuk
Copy link

filipsuk commented Jun 9, 2020

Hey @ArsenyYankovsky, not sure where to post this, but I am testing this feature in real environment and probably found a bug.

How to reproduce:

  1. Create entity containing column with uuid type primary generated column.
    @PrimaryGeneratedColumn('uuid')
    id: string;
    
  2. Try to perform schema:log cli command

Following error occurs:

TypeError: Cannot read property 'connect' of undefined
    at /src/driver/postgres/PostgresDriver.ts:325:26

I tried to debug this and it seems to be a problem with the afterConnect which uses pg pool and tries to add some postgres extensions for uuid. Probably custom implementation of afterConnect in AuroraDataApiPostgresDriver would solve this easily?

Source reference: https://github.com/typeorm/typeorm/blob/master/src/driver/postgres/PostgresDriver.ts#L325

EDIT: the problem is not in uuid type but in uuid generated column strategy:

@rudieros
Copy link

@filipsuk did you ever find a solution for this?

@metalcamp
Copy link

My hack was to generate uuid in app layer and use regular text field instead of uuid until I get more clear picture of the whole project and am able to open a PR. Very far from ideal, but it works at the moment.

@ArsenyYankovsky
Copy link
Owner Author

@metalcamp @filipsuk The UUID issue will be fixed with the new release of TypeORM. As a temporary solution until then you can build TypeORM from master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants