Comparing version 0.0.2-alpha.12 to 0.0.2-alpha.13
{ | ||
"name": "typeorm", | ||
"private": false, | ||
"version": "0.0.2-alpha.12", | ||
"version": "0.0.2-alpha.13", | ||
"description": "Data-mapper ORM for Typescript", | ||
@@ -6,0 +6,0 @@ "license": "Apache-2.0", |
@@ -98,3 +98,3 @@ "use strict"; | ||
this.addSelect(alias); | ||
return this.join("INNER", entityOrProperty, alias, conditionType, condition); | ||
return this.join("INNER", entityOrProperty, alias, conditionType, condition, parameters); | ||
}; | ||
@@ -104,3 +104,3 @@ QueryBuilder.prototype.innerJoin = function (entityOrProperty, alias, conditionType, condition, parameters) { | ||
if (condition === void 0) { condition = ""; } | ||
return this.join("INNER", entityOrProperty, alias, conditionType, condition); | ||
return this.join("INNER", entityOrProperty, alias, conditionType, condition, parameters); | ||
}; | ||
@@ -295,3 +295,7 @@ QueryBuilder.prototype.leftJoinAndSelect = function (entityOrProperty, alias, conditionType, condition, parameters) { | ||
.query(countQuery) | ||
.then(function (results) { return parseInt(results[0]["cnt"]); }); | ||
.then(function (results) { | ||
if (!results || !results[0] || !results[0]["cnt"]) | ||
return 0; | ||
return parseInt(results[0]["cnt"]); | ||
}); | ||
}; | ||
@@ -498,4 +502,11 @@ QueryBuilder.prototype.getResultsAndCount = function () { | ||
var inverseJoinColumnName = joinTable.inverseReferencedColumn.name; // not sure if this is correct | ||
var condition1 = junctionAlias + "." + junctionMetadata.columns[0].name + "=" + parentAlias + "." + joinTableColumn; // todo: use column names from junction table somehow | ||
var condition2 = joinAlias + "." + inverseJoinColumnName + "=" + junctionAlias + "." + junctionMetadata.columns[1].name; | ||
var condition1 = "", condition2 = ""; | ||
if (relation.isOwning) { | ||
condition1 = junctionAlias + "." + junctionMetadata.columns[0].name + "=" + parentAlias + "." + joinTableColumn; | ||
condition2 = joinAlias + "." + inverseJoinColumnName + "=" + junctionAlias + "." + junctionMetadata.columns[1].name; | ||
} | ||
else { | ||
condition1 = junctionAlias + "." + junctionMetadata.columns[1].name + "=" + parentAlias + "." + joinTableColumn; | ||
condition2 = joinAlias + "." + inverseJoinColumnName + "=" + junctionAlias + "." + junctionMetadata.columns[0].name; | ||
} | ||
return " " + joinType + " JOIN " + junctionTable + " " + junctionAlias + " " + join.conditionType + " " + condition1 + | ||
@@ -557,3 +568,3 @@ " " + joinType + " JOIN " + joinTableName + " " + joinAlias + " " + join.conditionType + " " + condition2 + appendedCondition; | ||
var value = _this.parameters[key] !== null && _this.parameters[key] !== undefined ? _this.driver.escape(_this.parameters[key]) : "NULL"; | ||
sql = sql.replace(":" + key, value); // todo: make replace only in value statements, otherwise problems | ||
sql = sql.replace(new RegExp(":" + key, "g"), value); // todo: make replace only in value statements, otherwise problems | ||
}); | ||
@@ -560,0 +571,0 @@ return sql; |
@@ -38,3 +38,7 @@ "use strict"; | ||
.map(function (group) { return _this.transformIntoSingleResult(group.items, alias, metadata); }) | ||
.filter(function (res) { return !!res; }); | ||
.filter(function (res) { return !!res; }) | ||
.map(function (res) { | ||
// console.log("res: ", res); | ||
return res; | ||
}); | ||
}; | ||
@@ -61,4 +65,5 @@ /** | ||
var relatedEntities = _this.groupAndTransform(rawSqlResults, relationAlias); | ||
var result = (relation.isManyToOne || relation.isOneToOne) ? relatedEntities[0] : relatedEntities; | ||
if (result) { | ||
var isResultArray = relation.isManyToMany || relation.isOneToMany; | ||
var result = !isResultArray ? relatedEntities[0] : relatedEntities; | ||
if (result && (!isResultArray || result.length > 0)) { | ||
if (relation.isLazy) { | ||
@@ -65,0 +70,0 @@ entity["__" + relation.propertyName + "__"] = result; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
645415
8946