-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: TypeORM support for Node.js Apps #22298
Comments
Thanks Thomas! |
@ThomasLohmann I'm fixing the proximate problem (the one in the error message you observe) in #22314. Once that is merged, we'd welcome the results of any further testing -- in case of further errors please post them here in follow-up comments. |
I just tested this out and with #22323 in place, the TypeORM demo seems to be working! There's probably more work to be done with this, but that's a good start. |
.... and now we're stuck on #9851. |
Hi there, any news about that issue? Kind regards, |
cc @awoods187 perhaps you can chime in? |
We are investigating pg compatibility errors like this for 2.1. More to come. |
@awoods187 what are your release plans for 2.1? |
@awoods187 the issue here is specifically the ability to change the data type of a column with ALTER. |
@ThomasLohmann we are in the process of finalizing it now. Do you have any requests that you'd like for me to be aware of? |
@awoods187 not for the moment. It would just be great if we find a solution for this problem as fast as possible. |
CockroachDB 2.0 has just been released |
@awoods187 and @knz any news on that issue? Kind regards, |
Hi Thomas! |
Sounds good! |
Update: @nvanbenschoten and I looked into this. The requirement to use ALTER SET TYPE was a red herring. The reason why TypeORM wants ALTER SET TYPE is that it sees a discrepancy between the schema specified in the entity and the schema reported by So adding support for ALTER SET TYPE would not be a good solution: a TypeORM app would then cause an expensive, wasteful column type change on every startup, whereas the correct solution is to make it satisfied that the current schema in-db is the one expected for the entities. Will investigate further to see where the discrepancy crops up. |
Found while working on cockroachdb#22298. This column was missed in cockroachdb#22753. It was displaying each constraint's database instead of each constraint's schema. Release note (bug fix): The constraint_schema column in information_schema.constraint_column_usage now displays the constraint's schema instead of its catalog.
Oh I see. Thanks for explaining. |
I filed this separate issue for that: #34831 |
@knz Hi everyone, TypeORM released an offical example with CockroachDB a few hours ago as you can see here: https://github.com/typeorm/cockroachdb-example or here is the closed issue ("pleerock" is the founder of TypeORM): Maybe you can add the example to your offical Docs as an alternative to Sequelize.js here: https://www.cockroachlabs.com/docs/stable/build-a-nodejs-app-with-cockroachdb-sequelize.html It would be really nice. I think after more than one year, we can finally close this issue. Kind regards, |
@ThomasLohmann we're still iterating on QAing these changes. We'll come back to this when we have asserted the result is of sufficient maturity to be advertised. Thanks! |
Hi @AlexMesser, upon advice from Umed we downloaded a copy of https://github.com/typeorm/cockroachdb-example We ran the following.
Can you clarify further what's happening here? I have used the latest version in our main repository Thank you |
@knz can you please run against |
Good idea, that indeed yields a difference in behavior. @bobvawter could you get the SQL exec traces on both crdb versions and point out where they diverge? |
Hey @knz, did you have a chance to make a complete test of TypeORM with a stable |
Can you explain what "a complete test" is? At this point we're just looking at the example provided above: https://github.com/typeorm/cockroachdb-example Do you have a more exhaustive test you'd like us to look at instead? |
okay, let me rephrase it. We have landed CockroachDB support in TypeORM. Everything works except something we have postponed for the future (email discussion). Example I provided is just a start point in the case if you want to start checking results. What's left to do from our side? |
@pleerock you have pointed out a difference in behavior between CockroachDB 2.1 and 19.1. I confirm we also see a difference, and we are still determining where it comes from. There are really two situations possible:
Unfortunately as of today I do not know which of the two points applies. Give us a little more time to investigate further. |
I've confirmed that 2.1.5 works correctly with the most recent release of typeorm. The current beta of cockroach fails due to the addition of the |
I take it back. While that is a difference, it isn't the cause of this problem. So far in my testing it's non-deterministic, and sometimes errors with the above error. |
35091: sql: rearchitecture ALTER TABLE RENAME, add support for renaming constraints r=knz a=knz Fixes #32555. For TypeORM compat, see discussion on #22298. Release note (sql change): This patch changes RENAME COLUMN to become a "table command", which can be used alongside other table commands in a single ALTER TABLE statement. This makes it possible to e.g. atomically add a computed column based on an existing column, and rename the columns so that the computed column "replaces" the original column. Release note (sql change): CockroachDB now supports ALTER TABLE RENAME CONSTRAINT for compatibility with PostgreSQL. This feature is limited to *named* constraints, where the name of the constraints is preserved in the table metadata. This currently includes CHECK, UNIQUE and FOREIGN KEY constraints, and does not include other constraints (DEFAULT, NULL etc) otherwise supported by PostgreSQL. For UNIQUE constraint, only supporting indexes that are not depended on by views can be renamed. 35121: sql: add support for pg_catalog.{current_setting,set_config} r=knz a=knz Fixes #35108. Needed for Flowable compatibility. Release note (sql change): The SQL built-in functions `pg_catalog.current_setting()` and `pg_catalog.set_config()` are now supported for compatibility with PostgreSQL. Note that only session-scoped configuration changes remain supported (`set_config(_, _, false)`). 35359: roachtest: backup: use AOST time slightly in the past r=mjibson a=mjibson Avoids problems where it's sometimes in the future according to the AOST logic. Fixes #34817 Release note: None 35371: sql: ensure column constraints are validated after SET for UPSERT r=knz a=knz Fixes #35040. Release note (bug fix): CockroachDB now properly applies column width and nullability constraints on the result of conflict resolution in UPSERT and INSERT ON CONFLICT. Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: Matt Jibson <[email protected]>
Some progress: I think this is caused by our handling of the It's possible that the best solution for this is for typeorm to run |
In 2.1, In 19.1, we completely removed the "naked" I guess the question is whether or not it's correct for a client to want to change a column from |
Ok now I understand fully. TypeORM issues a
Cockroach is going to fix this, but not until the release in later half of this year, because we decided to allow people 1 release to deal with this if they wanted (see the PR I linked above for more). |
We have applied suggested fix in the latest typeorm version ( You can continue testing TypeORM's CockroachDB support with the latest cockroachdb's master now. We have one issue however. For some reason CI randomly fails on a random test with following error:
Sometimes tests successfully pass, sometimes they throw this error. Fail example on CI. Any hint on why we have this error is appreciated. We are using the latest docker image from CRDB-unstable hub. Also side note. We have found your latest docker development image doesn't match the latest master and some changes are missing in there: (not sure how often master is released for docker, but what I imagine they should go in parallel) |
Hi all--you will need to setup a transaction retry loop as covered by these docs https://www.cockroachlabs.com/docs/v2.1/transactions.html#transaction-retries. Let us know if you have questions. |
We applied transaction retries to the latest version (I released changes in |
Amazing news! We will run a final set of internal tests tomorrow--thanks for all your hard work! I also filed #35876 to make sure we don't accidentally change anything that would impact TypeORM. |
Everything looks good on our end--we will try it out with some customers. I'm going to close this issue and will file new ones if they run into any problems! |
Hi there,
does anyone have an idea how to get TypeORM running with CockroachDB? I tried it out, but it doesn’t work. It would be really great if we find a solution, because Sequelize is bad compared to TypeORM. Furthermore, TypeScript is now state of the art on the backend.
TypeORM Link: http://typeorm.io/#/
Here is what I have tried so far and my error:
My TypeORM config:
I followed just the instructions by CockroachDB from here:
https://www.cockroachlabs.com/docs/stable/build-a-nodejs-app-with-cockroachdb.html
And my folder structure is nothing more than the TypeORM starter project:
npm instruction: typeorm init --name TypeORM --database postgres --express
If I just switch the config to my postgres database everything works.
The text was updated successfully, but these errors were encountered: