fixed findoptions bug and fixed tests

This commit is contained in:
Umed Khudoiberdiev 2016-04-21 23:29:04 +05:00
parent b919ef8bd7
commit 494af26f54
5 changed files with 8 additions and 9 deletions

View File

@ -766,7 +766,6 @@ usages.
ORM development is in progress. Api can be changed a lot. More documentation and features expected to be soon.
Feel free to contribute ;)
* add partial selection support (lot of problems with partial selection. Is there real benefit for users to use it?)
* in query builder should we use property names or table names? (right now its kinda mixed)
* should all entities have a primary column?
* think about indices
@ -774,11 +773,9 @@ Feel free to contribute ;)
* add cascadeAll to cascades?
* naming strategy need to be done correctly
* fix all propertyName/tableName problems and make sure everything work correctly
* check column types, make validation there
* foreign keys for relations
* what happens if owner one-to-one on both sides
* check self referencing
* array / json / date column types
* exceptions everywhere!
* add ability to load only ids of the relation (similar to loading only single id)
* make @Index and @CompoundIndex to work properly

View File

@ -1,7 +1,7 @@
{
"name": "typeorm",
"private": true,
"version": "0.0.2-alpha.1",
"version": "0.0.2-alpha.2",
"description": "Data-mapper ORM for Typescript",
"license": "Apache-2.0",
"readmeFilename": "README.md",

View File

@ -574,10 +574,9 @@ export class QueryBuilder<Entity> {
}
protected replaceParameters(sql: string) {
// todo: proper escape values and prevent sql injection
Object.keys(this.parameters).forEach(key => {
const value = this.parameters[key] !== null && this.parameters[key] !== undefined ? this.parameters[key] : "NULL";
sql = sql.replace(":" + key, this.connection.driver.escape(value)); // .replace('"', '')
const value = this.parameters[key] !== null && this.parameters[key] !== undefined ? this.connection.driver.escape(this.parameters[key]) : "NULL";
sql = sql.replace(":" + key, value);
});
return sql;
}

View File

@ -147,7 +147,7 @@ export class FindOptionsUtils {
*/
static isFindOptions(object: any): object is FindOptions {
const possibleOptions: FindOptions = object;
return possibleOptions.alias && typeof possibleOptions.alias === "string" && (
return possibleOptions && possibleOptions.alias && typeof possibleOptions.alias === "string" && (
!!possibleOptions.limit ||
!!possibleOptions.offset ||
!!possibleOptions.firstResult ||

View File

@ -27,7 +27,10 @@ describe("one-to-one", function() {
username: "root",
password: "admin",
database: "test",
autoSchemaCreate: true
autoSchemaCreate: true,
logging: {
logFailedQueryError: true
}
},
entities: [Post, PostDetails, PostCategory, PostMetadata, PostImage, PostInformation, PostAuthor]
};