fixed some failing tests

This commit is contained in:
Umed Khudoiberdiev 2017-05-19 14:48:25 +05:00
parent ce7f36b162
commit d7e06d7cc5
4 changed files with 9 additions and 9 deletions

View File

@ -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

View File

@ -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
});
});

View File

@ -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";

View File

@ -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.");
}));
});