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

chore: Merge master into next #6583

Merged
merged 174 commits into from
Sep 28, 2020
Merged

chore: Merge master into next #6583

merged 174 commits into from
Sep 28, 2020

Conversation

imnotjames
Copy link
Contributor

@imnotjames imnotjames commented Aug 19, 2020

This merges master into the next branch with a handful of extra commits to fix tests and other issues.

Changes I had to make to get the tests to pass:

commit change
2c9315e update FindOptionUtils to fix typing
0f292e3 update test to handle withDeleted living under FindOptions.optionswit…
cf15e3f default import for Observable
f46c8a3 work around typing preventing test 3416 from running
d2201ab fix test 6399
cbfbc56 SchemaTransformer requires a connection now
51da0ab correctly handle composite PK & failed entity loads
0128a9e FindCriteriaNotFoundError must extend EntityColumnNotFound
589c543 fix findOneOrFail passing invalid data to findOne
c88c863 drop generic from concrete EntityManagers
774c5ba update 4415 to address cockroachDB changes

dependabot bot and others added 30 commits March 14, 2020 00:22
Bumps [acorn](https://github.com/acornjs/acorn) from 5.7.3 to 5.7.4.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](acornjs/acorn@5.7.3...5.7.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Fix instruction on how to compile in watch mode. `--` is needed to pass arguments to npm scripts
* Add assertion test for issue typeorm#5762

* Fix handling of URL as a field value type

Fixes typeorm#5762

* Fix missing semicolon
there was no `sql` tag in the example, and `query` made the most sense.
…upport user specified values (typeorm#5867)

* Fixes typeorm#3271 - create-column, update-column, version-column column kinds now support user specified values

* removed .only

* create/update/version kind columns now considered as "changed" columns

* removed .only
word `returns` used twice
The code examples assume many results (see a comment below in each example), but queries were filtered by user.id. Instead groupBy clausule should be used in order to select user.id after using aggregation function.
Currently the disconnect() function does not perform a call to databaseConnection close, it only sets the
queryRunner and databaseConnection to undefined, this behavior may cause problems when you do something like this:

1 - await getConnection().close();
2 - Replace the database file
3 - Try to open connection createConnection(); and do some insert

more info:
expo/expo#8109
Just did not work with actual version of ts-node and others modules
* Fixed bug with unescaped comment string in MySQL driver.

* Added tests.

* Fixed linting issue.
Some of listed variables are not used anymore, some were are missing.
List is extracted from src/connection/options-reader/ConnectionOptionsEnvReader.ts
* [Add] FOR NO KEY UPDATE lock mode for postgresql

* [Add] for no key update lock test

* [Fix] lint

* [Fix] test

Co-authored-by: JeyongOh <jeyong.oh@gogo-ssing.com>
Add 'name' option to @ViewColumn to align with @column
and allow a different property name for a column in a view.

Closes typeorm#5708
Change "lets" to "let's" in the sentence "since we have errors lets [sic] rollback changes we made".
…correctly (typeorm#5947)

* [UPDATE] Update insert and update query builder to handle mssql geometry column with SRID properly

* [FIX] Fix indentation with spaces

* [FIX] Fix semicolon, and quota characters

* [FIX] Fix semicolon

Co-authored-by: Paul Kwok <wkkwok@uacs.hk>
The "entitySchemas" connection option doesn't work. Instead, schemas are recognized when added to the "entities" connection option. The docs were updated to reflect that.
* Added support for NOWAIT & SKIP LOCKED in Postgres

* fix merge typo

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
…m#5878)

This method returns an object with `_id` and `index` properties, according to [the description of `BulkWriteResult`](https://docs.mongodb.com/manual/reference/method/BulkWriteResult/#BulkWriteResult.upserted).
* Data API Postgres WIP

* Refactored the code to be more supportable
* Implement soft remove and recover for entity.

* Add test for entity soft remove and recover.

* Fix entity soft remove and recover test.
Louai-H and others added 8 commits September 17, 2020 16:16
* Update many-to-many-relations.md

* Update many-to-many-relations.md

Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com>
…peorm#6215)

This feature for postgres connections means when you pass the logNotifications option, db notices and notifications will be passed to the logger with info log level

Closes: typeorm#2216
…eorm#6743)

currently we pull in BetterSqlite3Driver, SqliteDriver, and a few other
drivers & files that aren't possible to use in a browser context.
this change adds some more browser compatibility features so
webpack builds targeted at browsers will be able to complete

closes typeorm#6739
…m#6745)

* fix: count() method for multiple primary keys for cockroachdb

Cockroachdb does not support concat() for different types at the moment.
To fix this problem, each primary key is cast to the text type.

* fix: add doublequote

* fix: add doublequote

* test: update and move tests for count() method for multiple primary keys

* fix: count() method for multiple primary keys for oracle

Oracle does not support CONCAT() for more than 2 arguments at the moment.
To solve this problem, operator || is used instead of CONCAT().
…eorm#6747)

create a type to track ReplicationMode instead of writing out
`"master"|"slave"` everywhere.

update to drop the default from the QueryRunner constructor
as they will always receive the mode from the driver when
it's part of the QueryRunner

also drop the default from Driver.createQueryRunner in the
implementations - the interface mandates the mode to be defined
so it will never be omitted anyway

also drop the explict "master" from any connection.createQueryRunner
calls so we leave it either the default or `slave` when needed

all of this makes it easier to eventually migrate to
other naming convetions for the replication mode
should it be deemed the right path to go down
* stop using PromiseUtils.create & extractValue as they're doing nothing

because we never use PromiseUtils.create, PromiseUtils.extract was technically
never used either - the only case we were using this was in a test
where we can replace it with Promise.resolve

* stop using PromiseUtils.settle in test 1014

there was no reason to use this call in the test
as it was not using the results and only used the `Promise.all`
functionality

* use Promise.all instead of PromiseUtils.runInSequence in tests

in these cases of PromiseUtils.runInSequence in tests there was no need
for us to be running them in sequence - so instead we could use Promise.all
& Array.map for a replacement.  removes the dependency on PromiseUtils &
also speeds up our tests

* run tests sequentially for those that deal with ActiveRecord

because the activerecord mechanism creates a "global" scope through
the class that ActiveRecord is applied to we have to run through the
connections sequentially or end up with them being all over the place
as far as what activerecord model is connected to what connection

* use standard async/await + for/of instead of runInSequence

in cases where actual order of the runs matter we can do for/of
and then await any of the results - because none of the usages of
runInSequence that rely on the correct order actually use the results

* use Promise.all on runInSequence cases where order doesn't matter

* drop PromiseUtils altogether

* sequentially run when dealing with QueryRunner

queryrunner is not 'thread-safe' or async safe

* drop the test to lookup by Promise

before, the test wasn't validating that you could lookup by promise
the test was verifying that if you used something that wasn't a promise
but instead had a magic __value__ variable you'd get a lookup

that's not a promise, unfortunately

I can't find that a promise may be passed into the find options anywhere
in the documentation so I've removed this test
* fix: resolve issues ora-00972:identifier is too long

Closes: typeorm#5067

* fix: ensure that this changes applies just for Oracle Driver

Closes: typeorm#5067

* fix test - remove `.only` & set the `enabledDrivers` to oracle

* simplify test case

Co-authored-by: Murat Gundes <guendes.murat@indivumed.com>
@imnotjames
Copy link
Contributor Author

Merged master a second time - mostly to get the oracle fixes in so those tests pass. Once all the tests pass I'll iterate through the changes I made to ensure the tests pass between master and next

@imnotjames
Copy link
Contributor Author

imnotjames commented Sep 25, 2020

Looks like something in the next branch causes the query pattern to be drastically different in the next branch - not just this PR, either.

Master:

SELECT DISTINCT "distinctAlias"."User_primaryKey" as "ids_User_primaryKey" FROM (SELECT "User"."primaryKey" AS "User_primaryKey", "User"."email" AS "User_email", "User__access_token"."primaryKey" AS "User__access_token_primaryKey", "User__access_token"."userPrimaryKey" AS "3115cc2fef583c2761dee1374a5720" FROM "user" "User" LEFT JOIN "access_token" "User__access_token" ON "User__access_token"."userPrimaryKey"="User"."primaryKey" WHERE "User"."email" = :1) "distinctAlias"  ORDER BY "User_primaryKey" ASC FETCH NEXT 1 ROWS ONLY

SELECT "User"."primaryKey" AS "User_primaryKey", "User"."email" AS "User_email", "User__access_token"."primaryKey" AS "User__access_token_primaryKey", "User__access_token"."userPrimaryKey" AS "3115cc2fef583c2761dee1374a5720" FROM "user" "User" LEFT JOIN "access_token" "User__access_token" ON "User__access_token"."userPrimaryKey"="User"."primaryKey" WHERE ( "User"."email" = :1 ) AND ( "User"."primaryKey" IN (1) )

next branch (with & without merged in master)

SELECT "User"."primaryKey" AS "User_primaryKey", "User"."email" AS "User_email" FROM "user" "User" WHERE ("User"."email" = :1) FETCH NEXT 1 ROWS ONLY

SELECT "AccessToken"."primaryKey" AS "AccessToken_primaryKey", "AccessToken"."userPrimaryKey" AS "AccessToken_userPrimaryKey" FROM "access_token" "AccessToken" WHERE "AccessToken"."userPrimaryKey" IN (1)

SELECT "AccessToken"."primaryKey" AS "AccessToken_access_token_primaryKey", "AccessToken"."userPrimaryKey" AS "User_primaryKey" FROM "access_token" "AccessToken" WHERE "AccessToken"."userPrimaryKey" IN (1)

That's causing the oracle failures.. I'm thinking of just disabling this test but..

@imnotjames
Copy link
Contributor Author

imnotjames commented Sep 26, 2020

I attempted to skip that test but it seems like it just breaks in a test that also runs through that behavior. The area that's causing this behavior is:

relation.entityMetadata.primaryColumns.forEach(primaryColumn => {
const columnName = primaryColumn.entityMetadata.name + "_" + relation.inverseRelation!.propertyPath.replace(".", "_") + "_" + primaryColumn.propertyPath.replace(".", "_");
qb.addSelect(mainAlias + "." + primaryColumn.propertyPath, columnName);
});
relation.joinColumns.forEach(column => {
const columnName = column.referencedColumn!.entityMetadata.name + "_" + column.referencedColumn!.propertyPath.replace(".", "_");
qb.addSelect(mainAlias + "." + column.propertyPath, columnName);
});

I tried to use column.propertyAliasName instead of the madness that it uses there, but that breaks other tests where they can't associate the data into the related models. Probably somewhere else that looks for these.

Path forward right now is to dig into that further, some minor refactoring of the RelationIdLoader & others so it uses something that will listen to the alias values - add that commit to next & also to a PR for master.

Branch with just that change.

@imnotjames imnotjames marked this pull request as ready for review September 28, 2020 01:56
@imnotjames
Copy link
Contributor Author

imnotjames commented Sep 28, 2020

We could just merge it as is - eg, with the failing oracle test. I'm pretty sure the failing oracle tests are due to the next branch & not the merge. I saw similar results running the oracle tests against the upstream next branch as well.

@pleerock thoughts?

PS I updated the body of the PR to include the extra commits I created for it and why

@pleerock
Copy link
Member

Thank you @imnotjames . Let's merge, I'll release a new next version and let's keep track on newly reported issues (there are not so many next users afaik). Also, what do we need to do to fix oracle issues on next ?

@pleerock
Copy link
Member

according to CI, ORA-00972: identifier is too long is an error. Looks like we need to enable logging, check which query fails and where identifier isn't shortened?

@imnotjames
Copy link
Contributor Author

imnotjames commented Sep 28, 2020

Also if you'd like tos we the queries that are causing this they're in a comment above.

@pleerock
Copy link
Member

oh, okay.. so, for your question on why it creates different queries - because in next branch have a different approach on loading relations - instead of using joins, it creates creates and runs separate queries.

on question why it fails - you probably remember that Oracle has a limitation on length of the identifiers - aliases and other similar symbols. So, my assumption is we don't shorten alias here, that's why we have an error.

Maybe placing a following code (taken from FindOptionsUtils`):

            let relationAlias: string = alias + "__" + relation;
            // shorten it if needed by the driver
            if (qb.connection.driver.maxAliasLength && relationAlias.length > qb.connection.driver.maxAliasLength) {
                relationAlias = shorten(relationAlias);
            }

in the code you provided can fix the issue.

@imnotjames
Copy link
Contributor Author

on question why it fails - you probably remember that Oracle has a limitation on length of the identifiers - aliases and other similar symbols. So, my assumption is we don't shorten alias here, that's why we have an error.

Right - I had made that change, more or less, and found that while we didn't get the issue with oracle, elsewhere we had a failure with the alias being expected as what it previously was.

The amount of change needed to correct the issue started to feel a bit out of the scope for this PR - as the test was failing silently before, and it seems like this code should have been an issue before as well.

@pleerock
Copy link
Member

Okay, let's merge it. Thank you a lot

@pleerock pleerock merged commit 903765d into typeorm:next Sep 28, 2020
@thynson
Copy link

thynson commented Sep 28, 2020

Will there be a new rc release? Can't wait for it!

@pleerock
Copy link
Member

released in typeorm@0.3.0-rc.20

@nebkat
Copy link
Contributor

nebkat commented Nov 22, 2020

Was this mistakenly merged as a squash? imnotjames@b2eeba6 correctly maintains commit history from both branches but 903765d does not. next...imnotjames:next shows the missing commits.

This is a problem for merging between the two branches now, as next...master shows commits since April 13th, while imnotjames/typeorm@next...typeorm:master shows only from after September 26th.

@pleerock
Copy link
Member

@nebkat I'm not sure... what is a proper resolution? revert changes and merge once again?

@nebkat
Copy link
Contributor

nebkat commented Jan 12, 2021

If you're willing to accept a broken history on the next branch the best resolution would be to hard reset before the squash happened and then do the merge. I don't think there are many pull requests for next so doubt a lot of people would be affected (most importantly master will remain good).

With revert it won't break history for those who have a local copy of the next branch, but when looking through git blame/history for a file it will be annoying in future.

I can do either option on my fork if you want?

nebkat added a commit to nebkat/typeorm that referenced this pull request Jan 18, 2021
@nebkat
Copy link
Contributor

nebkat commented Jan 18, 2021

I thought you had done some additional changes on top of @imnotjames' commit but I see it is identical just squashed. If you are OK with the hard reset/broken history route I have pushed it here nebkat@28688b8.

pleerock added a commit that referenced this pull request Feb 25, 2021
@imnotjames imnotjames deleted the next branch June 21, 2021 00:10
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

Successfully merging this pull request may close these issues.

None yet