initialize db only once
このコミットが含まれているのは:
		
						コミット
						c753630a29
					
				| @ -12,15 +12,6 @@ function wrap(db, dir, dbsMap) { | |||||||
|     dbsMap = {}; |     dbsMap = {}; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   db.escape = function (str) { |  | ||||||
|     // TODO? literals for true,false,null
 |  | ||||||
|     // error on undefined?
 |  | ||||||
|     if (undefined === str) { |  | ||||||
|       str = ''; |  | ||||||
|     } |  | ||||||
|     return String(str).replace(/'/g, "''"); |  | ||||||
|   }; |  | ||||||
| 
 |  | ||||||
|   function lowerFirst(str) { |   function lowerFirst(str) { | ||||||
|     return str.charAt(0).toLowerCase() + str.slice(1); |     return str.charAt(0).toLowerCase() + str.slice(1); | ||||||
|   } |   } | ||||||
| @ -157,19 +148,6 @@ function wrap(db, dir, dbsMap) { | |||||||
|     dir.indices.forEach(normalizeColumn); |     dir.indices.forEach(normalizeColumn); | ||||||
|     DB._indices = dir.indices; |     DB._indices = dir.indices; | ||||||
| 
 | 
 | ||||||
|     db = PromiseA.promisifyAll(db); |  | ||||||
| 
 |  | ||||||
|     if (dir && dir.verbose || db.verbose) { |  | ||||||
|       console.log('Getting Verbose up in here'); |  | ||||||
|       db.on('trace', function (str) { |  | ||||||
|         console.log('SQL:', str); |  | ||||||
|       }); |  | ||||||
| 
 |  | ||||||
|       db.on('profile', function (sql, ms) { |  | ||||||
|         console.log('Profile:', ms); |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     function simpleParse(row) { |     function simpleParse(row) { | ||||||
|       if (!row) { |       if (!row) { | ||||||
|         return null; |         return null; | ||||||
| @ -581,6 +559,32 @@ function wrap(db, dir, dbsMap) { | |||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   if (!db.__masterquest_init) { | ||||||
|  |     db.__masterquest_init = true; | ||||||
|  |     db = PromiseA.promisifyAll(db); | ||||||
|  |     db.__masterquest_init = true; | ||||||
|  |     db.escape = function (str) { | ||||||
|  |       // TODO? literals for true,false,null
 | ||||||
|  |       // error on undefined?
 | ||||||
|  |       if (undefined === str) { | ||||||
|  |         str = ''; | ||||||
|  |       } | ||||||
|  |       return String(str).replace(/'/g, "''"); | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  |     if (dir && dir.verbose || db.verbose) { | ||||||
|  |       console.log('Getting Verbose up in here'); | ||||||
|  |       db.on('trace', function (str) { | ||||||
|  |         console.log('SQL:', str); | ||||||
|  |       }); | ||||||
|  | 
 | ||||||
|  |       db.on('profile', function (sql, ms) { | ||||||
|  |         console.log('Profile:', ms); | ||||||
|  |       }); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   dbsMap.sql = db; | ||||||
|  | 
 | ||||||
|   dir.forEach(function (dir) { |   dir.forEach(function (dir) { | ||||||
|     // TODO if directive is the same as existing dbsMap, skip it
 |     // TODO if directive is the same as existing dbsMap, skip it
 | ||||||
|     promises.push(createTable(dir).then(function (dbw) { |     promises.push(createTable(dir).then(function (dbw) { | ||||||
| @ -591,8 +595,6 @@ function wrap(db, dir, dbsMap) { | |||||||
|     })); |     })); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   dbsMap.sql = db; |  | ||||||
| 
 |  | ||||||
|   return PromiseA.all(promises).then(function (/*dbs*/) { |   return PromiseA.all(promises).then(function (/*dbs*/) { | ||||||
|     return dbsMap; |     return dbsMap; | ||||||
|   }); |   }); | ||||||
|  | |||||||
		読み込み中…
	
	
			
			x
			
			
		
	
		新しいイシューから参照
	
	ユーザーをブロックする