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
0.3.0 #8616
Conversation
… support; bugfixing; added some changes and tests from next branch;
… deprecations; new es2020 emit by tsc; new custom repositories syntax
Can you provide rationale on this? |
This comment was marked as resolved.
This comment was marked as resolved.
@pleerock When might you consider switching to a 1.x release? |
* | ||
* (works like a discriminator property). | ||
*/ | ||
readonly typename?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be sensible to make it string | symbol
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pleerock It's useful to have discriminator property not returned through JSON.stringify and not conflicting with any possible column name.
remove ex-line 26 for being deprecated in 0.3.0: "* `primary: boolean` - Indicates whether this relation's column will be a primary column or not."
…ors" This reverts commit 7bf12a3.
This reverts commit 7588ac1.
This reverts commit bfa5a2d.
…will throw an error and it's not clear what kind of error its going to throw
@Ginden yes we can, but it will also work on node 12, because I think we don't use anything node-14 specific. But yes, officially we can say we support 14+. |
Hey! I was just testing typeorm rc and migrating my project over and encountered some difficulties with extending a tree repository for posts compared to how I did it previously I required the protected functions of creating relationship maps and building children entity tree so I could implement my own way of only fetching up to say 20 of the top level children posts and paginating those children posts, but now I cannot access this, is there any other way I can migrate across? Edit: Aside from that everything works fine! The query logs in console are also much neater now, can't wait till this is actually released 🙂 |
@Q16solver thanks for testing! Oh yeah protected methods are not accessible now. We have two options: make them public (but it will be temporary approach), or refactor the code in the TreeRepository and extract functionality into separate class, for example into |
@pleerock Sweet! I'll just do a simple refactor into TreeRepositoryUtils in the utils folder, I don't believe we will need to add new test cases for this as there shouldn't be any drastic changes, however, in saying that I do also realise that the extends method only covers the general repository case as well, and I'm thinking if I can add an override extends type in TreeRepository Edit: Done that and made a PR #8753! Hopefully it's exactly what you wanted |
* Migrated protected tree methods to util class * Added tree repository extend override * Ran prettier format
Trivial merge conflict fix PR #8754 for formatting spaces, it passes linting so it should be fine |
Co-authored-by: Bitcollage <serkan.sipahi@yahoo.de>
@Q16solver I don't really expect to merge something non-trivial into |
# Conflicts: # sample/sample5-subscribers/subscriber/EverythingSubscriber.ts
참고 : typeorm/typeorm#8616 > "primary relation (e.g. @manytoone(() => User, { primary: true }) user: User) support is removed. ..."
0.3.0 (2022-03-17)
Changes in the version includes changes from the
next
branch andtypeorm@next
version.They were pending their migration from 2018. Finally, we are ready to merge them into master and release new
0.3.0
.FEATURES
compilation
target
now ises2020
. This requires Node.JS version12.9.0
+Connection
was renamed toDataSource
.Old
Connection
is still there, but now it's deprecated. It will be removed in next version.New API:
Previously, you could use
new Connection()
,createConnection()
,getConnectionManager().create()
, etc.They all deprecated in favour of new syntax you can see above.
New way gives you more flexibility and simplicity in usage.
Old ways of custom repository creation were deprecated.
added new option on relation load strategy called
relationLoadStrategy
.Relation load strategy is used on entity load and their relations load when you query entities from the database.
Used on
find*
methods andQueryBuilder
. Value can be set tojoin
orquery
.join
loads relations using SQL'sJOIN
query
executes separate SQL queries for each relationDefault is
join
, but default can be set inConnectionOptions
:Also, it can be set per-query in
find*
methods:And QueryBuilder:
For queries returning big amount of data, we recommend to use
query
strategy,because it can be a more performant approach to query relations.
select
type signature inFindOptions
(used infind*
methods):Also, now it's possible to specify select columns of the loaded relations:
relations
type signature inFindOptions
(used infind*
methods):To load nested relations use a following signature:
order
type signature inFindOptions
(used infind*
methods):Now supports nested order by-s:
where
type signature inFindOptions
(used infind*
methods) now allows to build nested statements with conditional relations, for example:Gives you users who have photos in their "profile" album.
FindOperator
-s can be applied for relations inwhere
statement, for example:Gives you users with more than 10 photos.
boolean
can be applied for relations inwhere
statement, for example:DEPRECATIONS
select
inFindOptions
(used infind*
methods) used as an array of property names is deprecated.Now you should use a new object-literal notation. Example:
Deprecated way of loading entity relations:
New way of loading entity relations:
This change is due to type-safety improvement new
select
signature brings.relations
inFindOptions
(used infind*
methods) used as an array of relation names is deprecated.Now you should use a new object-literal notation. Example:
Deprecated way of loading entity relations:
New way of loading entity relations:
This change is due to type-safety improvement new
relations
signature brings.join
inFindOptions
(used infind*
methods) is deprecated. UseQueryBuilder
to build queries containing manual joins.Connection
,ConnectionOptions
are deprecated, new names to use are:DataSource
andDataSourceOptions
.To create the same connection you had before use a new syntax:
new DataSource({ /*...*/ })
.createConnection()
,createConnections()
are deprecated, sinceConnection
is calledDataSource
now, to create a connection and connect to the databasesimply do:
getConnection()
is deprecated. To have a globally accessible connection, simply export your data source and use it in places you need it:getManager()
,getMongoManager()
,getSqljsManager()
,getRepository()
,getTreeRepository()
,getMongoRepository()
,createQueryBuilder()
are all deprecated now. Use globally accessible data source instead:
getConnectionManager()
andConnectionManager
itself are deprecated - nowConnection
is calledDataSource
,and each data source can be defined in exported variable. If you want to have a collection
of data sources, just define them in a variable, simply as:
getConnectionOptions()
is deprecated - in next version we are going to implement different mechanism of connection options loadingAbstractRepository
is deprecated. Use new way of custom repositories creation.@TransactionRepository
,@TransactionManager
,@Transaction
decorators were deprecated.all deprecated signatures will be removed in
0.4.0
BREAKING CHANGES
minimal Node.JS version requirement now is
12.9.0
now migrations are running before schema synchronization if you have both pending migrations and schema synchronization pending
(it works if you have both
migrationsRun
andsynchronize
enabled in connection options).findOne
andQueryBuilder.getOne()
now returnnull
instead ofundefined
in the case if it didn't find anything in the database.Logically it makes more sense to return
null
.where
inFindOptions
(e.g.find({ where: { ... })
) is more sensitive to input criteria now.if you had entity properties of a non-primitive type (except Buffer) defined as columns,
then you won't be able to use it in
find*
'swhere
. Example:Before for the
@Column(/*...*/) membership: MembershipKind
you could have a query like:now, you need to wrap this value into
Equal
operator:This change is due to type-safety improvement new
where
signature brings.order
inFindOptions
(used infind*
methods) doesn't support ordering by relations anymore.Define relation columns, and order by them instead.
where
inFindOptions
(used infind*
methods) previously supportedObjectLiteral
andstring
types.Now both signatures were removed. ObjectLiteral was removed because it seriously breaks the type safety,
and
string
doesn't make sense in the context ofFindOptions
. UseQueryBuilder
instead.MongoRepository
andMongoEntityManager
now use new types calledMongoFindManyOptions
andMongoFindOneOptions
for their
find*
methods.primary relation
(e.g.@ManyToOne(() => User, { primary: true }) user: User
) support is removed.You still have an ability to use foreign keys as your primary keys,
however now you must explicitly define a column marked as primary.
Example, before:
Now:
Primary column name must match the relation name + join column name on related entity.
If related entity has multiple primary keys, and you want to point to multiple primary keys,
you can define multiple primary columns the same way:
This change was required to simplify ORM internals and introduce new features.
EXPERIMENTAL FEATURES NOT PORTED FROM NEXT BRANCH
observers
- we will consider returning them back with new API in future versionsalternative find operators
- using$any
,$in
,$like
and other operators inwhere
condition.THINGS I ASK TO HELP ME WITH
npm i typeorm@rc
)