Skip to content

Commit

Permalink
Apostrophe hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodonisko committed Jan 6, 2017
1 parent c0d21a4 commit 0993873
Show file tree
Hide file tree
Showing 5 changed files with 1,070 additions and 8 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ionic-cache",
"version": "1.1.0",
"version": "1.1.1",
"description": "Ionic cache service - cache request, data, promises etc.",
"main": "ionic-cache.js",
"scripts": {
Expand All @@ -23,11 +23,12 @@
},
"homepage": "https://github.com/Nodonisko/ionic-cache#readme",
"dependencies": {
"@angular/common": "^2.4.2",
"@angular/core": "^2.0.2",
"@angular/http": "^2.0.2",
"@angular/platform-browser": "^2.0.2",
"rxjs": "^5.0.0-beta.12",
"zone.js": "^0.6.21"
"rxjs": "^5.0.0-beta.12",
"zone.js": "^0.7.4"
},
"devDependencies": {
"tslint": "^3.15.1",
Expand Down
4 changes: 2 additions & 2 deletions src/cache.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ export class CacheService {
const valuesMap = { key, value, expire, type, groupKey };
const values = Object.keys(valuesMap).map(key => `'${valuesMap[key]}'`);

let query = `INSERT OR REPLACE INTO ${this.tableName} (${Object.keys(valuesMap).join(', ')}) VALUES (${values.join(', ')})`;
let query = `INSERT OR REPLACE INTO ${this.tableName} (${Object.keys(valuesMap).join(', ')}) VALUES (${values.map(()=>'?').join(', ')})`;

return this.storage.query(query).then(() => data);
return this.storage.query(query, values).then(() => data);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export class SqlStorage {
* @description Call database query
* @return {Promise<any>}
*/
public query(query: String): Promise<any> {
public query(query: String, values: any[] = []): Promise<any> {
return new Promise((resolve, reject) => {
this.database.transaction((tx) => {
tx.executeSql(query, [], (tx, rs) => {
tx.executeSql(query, values, (tx, rs) => {
resolve(rs);
}, (tx, err) => {
reject(err);
Expand Down
1 change: 0 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
{
"extends": "tslint-ionic-rules"
}
Loading

0 comments on commit 0993873

Please sign in to comment.