mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
fixed some failing tests
This commit is contained in:
parent
ce7f36b162
commit
d7e06d7cc5
@ -18,9 +18,9 @@ each for its own `findOne*` or `find*` methods
|
||||
* table decorators were not removed in the release, however they will be removed in next. Be sure to replace them before that.
|
||||
* `QueryBuilder#setFirstResult` has been renamed to `QueryBuilder#skip`
|
||||
* `QueryBuilder#setMaxResults` has been renamed to `QueryBuilder#take`
|
||||
* renamed `entityManager` to `manager`
|
||||
* renamed `entityManager` to `manager` in `Connection` object
|
||||
* renamed `persist` to `save` in `EntityManager` and `Repository` objects
|
||||
* `@AbstractEntity` is deprecated. Now there is no need to mark class with a decorator, it can extend any class with columns
|
||||
*
|
||||
|
||||
### NEW FEATURES
|
||||
|
||||
|
||||
@ -1437,15 +1437,15 @@ export class QueryBuilder<Entity> {
|
||||
this.expressionMap.aliases.forEach(alias => {
|
||||
if (!alias.hasMetadata) return;
|
||||
alias.metadata.columns.forEach(column => {
|
||||
const expression = "([ =\(]|^.{0})" + alias.name + "\\." + column.propertyPath + "([ =\)]|.{0}$)";
|
||||
const expression = "([ =\(]|^.{0})" + alias.name + "\\." + column.propertyPath + "([ =\)\,]|.{0}$)";
|
||||
statement = statement.replace(new RegExp(expression, "gm"), "$1" + this.escapeAlias(alias.name) + "." + this.escapeColumn(column.databaseName) + "$2");
|
||||
});
|
||||
alias.metadata.relationsWithJoinColumns.forEach(relation => {
|
||||
relation.joinColumns.forEach(joinColumn => {
|
||||
const expression = "([ =\(]|^.{0})" + alias.name + "\\." + relation.propertyPath + "\\." + joinColumn.referencedColumn!.propertyPath + "([ =\)]|.{0}$)";
|
||||
const expression = "([ =\(]|^.{0})" + alias.name + "\\." + relation.propertyPath + "\\." + joinColumn.referencedColumn!.propertyPath + "([ =\)\,]|.{0}$)";
|
||||
statement = statement.replace(new RegExp(expression, "gm"), "$1" + this.escapeAlias(alias.name) + "." + this.escapeColumn(joinColumn.databaseName) + "$2"); // todo: fix relation.joinColumns[0], what if multiple columns
|
||||
});
|
||||
const expression = "([ =\(]|^.{0})" + alias.name + "\\." + relation.propertyPath + "([ =\)]|.{0}$)";
|
||||
const expression = "([ =\(]|^.{0})" + alias.name + "\\." + relation.propertyPath + "([ =\)\,]|.{0}$)";
|
||||
statement = statement.replace(new RegExp(expression, "gm"), "$1" + this.escapeAlias(alias.name) + "." + this.escapeColumn(relation.joinColumns[0].databaseName) + "$2"); // todo: fix relation.joinColumns[0], what if multiple columns
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import {Repository} from "./Repository";
|
||||
import {getConnection, getRepository} from "../index";
|
||||
import {getConnection} from "../index";
|
||||
import {QueryBuilder} from "../query-builder/QueryBuilder";
|
||||
import {DeepPartial} from "../common/DeepPartial";
|
||||
import {PersistOptions} from "./PersistOptions";
|
||||
|
||||
@ -20,15 +20,15 @@ describe("entity-model", () => {
|
||||
|
||||
const post = new Post();
|
||||
post.title = "About ActiveRecord";
|
||||
post.text = "Huge description how good or bad ActiveRecord is.";
|
||||
post.text = "Huge discussion how good or bad ActiveRecord is.";
|
||||
await post.save();
|
||||
|
||||
const loadedPost = await Post.findOneById(1);
|
||||
const loadedPost = await Post.findOneById<Post>(1);
|
||||
|
||||
loadedPost!.should.be.instanceOf(Post);
|
||||
loadedPost!.id.should.be.eql(1);
|
||||
loadedPost!.title.should.be.eql("About ActiveRecord");
|
||||
loadedPost!.text.should.be.eql("Huge description how good or bad ActiveRecord is.");
|
||||
loadedPost!.text.should.be.eql("Huge discussion how good or bad ActiveRecord is.");
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user