minorm
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -99,2 +99,6 @@ 'use strict'; | ||
var _ref = new Error(); | ||
const stack = _ref.stack; | ||
var _query$toParam = query.toParam(); | ||
@@ -106,3 +110,10 @@ | ||
logger && logger.debug(`SQL query: ${text}`); | ||
return getPool().query(text, values); | ||
return getPool().query(text, values).catch(err => { | ||
const newErr = new Error(`${err.message} | ||
Query: ${text} | ||
Call stack for query: ${stack} | ||
`); | ||
// newErr.stack = stack | ||
throw newErr; | ||
}); | ||
}, | ||
@@ -114,2 +125,6 @@ nestQuery(query) { | ||
var _ref2 = new Error(); | ||
const stack = _ref2.stack; | ||
var _query$toParam2 = query.toParam(); | ||
@@ -124,3 +139,9 @@ | ||
nestTables: true | ||
}, values); | ||
}, values).catch(err => { | ||
const newErr = new Error(`${err.message} | ||
Query: ${text} | ||
Call stack for query: ${stack} | ||
`); | ||
throw newErr; | ||
}); | ||
}, | ||
@@ -127,0 +148,0 @@ startQuery() { |
@@ -38,19 +38,8 @@ 'use strict'; | ||
execute() { | ||
let nested = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
return this._manager.query(this).then((_ref) => { | ||
var _ref2 = _slicedToArray(_ref, 1); | ||
if (nested) { | ||
return this._manager.nestQuery(this).then((_ref) => { | ||
var _ref2 = _slicedToArray(_ref, 1); | ||
let result = _ref2[0]; | ||
return result; | ||
}); | ||
} else { | ||
return this._manager.query(this).then((_ref3) => { | ||
var _ref4 = _slicedToArray(_ref3, 1); | ||
let result = _ref4[0]; | ||
return result; | ||
}); | ||
} | ||
let result = _ref2[0]; | ||
return result; | ||
}); | ||
} | ||
@@ -57,0 +46,0 @@ } |
@@ -28,19 +28,8 @@ 'use strict'; | ||
execute() { | ||
let nested = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
return this._manager.query(this).then((_ref) => { | ||
var _ref2 = _slicedToArray(_ref, 1); | ||
if (nested) { | ||
return this._manager.nestQuery(this).then((_ref) => { | ||
var _ref2 = _slicedToArray(_ref, 1); | ||
let result = _ref2[0]; | ||
return result; | ||
}); | ||
} else { | ||
return this._manager.query(this).then((_ref3) => { | ||
var _ref4 = _slicedToArray(_ref3, 1); | ||
let result = _ref4[0]; | ||
return result; | ||
}); | ||
} | ||
let result = _ref2[0]; | ||
return result; | ||
}); | ||
} | ||
@@ -47,0 +36,0 @@ } |
@@ -34,19 +34,8 @@ 'use strict'; | ||
execute() { | ||
let nested = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; | ||
return this._manager.query(this).then((_ref) => { | ||
var _ref2 = _slicedToArray(_ref, 1); | ||
if (nested) { | ||
return this._manager.nestQuery(this).then((_ref) => { | ||
var _ref2 = _slicedToArray(_ref, 1); | ||
let result = _ref2[0]; | ||
return result; | ||
}); | ||
} else { | ||
return this._manager.query(this).then((_ref3) => { | ||
var _ref4 = _slicedToArray(_ref3, 1); | ||
let result = _ref4[0]; | ||
return result; | ||
}); | ||
} | ||
let result = _ref2[0]; | ||
return result; | ||
}); | ||
} | ||
@@ -53,0 +42,0 @@ } |
{ | ||
"name": "minorm", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "MinORM - Light high-performance ORM for MySQL", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -80,5 +80,15 @@ /** @flow */ | ||
} | ||
const { stack } = new Error | ||
const {text, values} = query.toParam() | ||
logger && logger.debug(`SQL query: ${text}`) | ||
return getPool().query(text, values) | ||
return getPool().query(text, values).catch( | ||
err => { | ||
const newErr = new Error(`${err.message} | ||
Query: ${text} | ||
Call stack for query: ${stack} | ||
`) | ||
// newErr.stack = stack | ||
throw newErr | ||
} | ||
) | ||
}, | ||
@@ -89,2 +99,3 @@ nestQuery(query) { | ||
} | ||
const { stack } = new Error | ||
const {text, values} = query.toParam() | ||
@@ -95,3 +106,11 @@ logger && logger.debug(`SQL query: ${text}`) | ||
nestTables: true | ||
}, values) | ||
}, values).catch( | ||
err => { | ||
const newErr = new Error(`${err.message} | ||
Query: ${text} | ||
Call stack for query: ${stack} | ||
`) | ||
throw newErr | ||
} | ||
) | ||
}, | ||
@@ -98,0 +117,0 @@ startQuery() { |
@@ -26,8 +26,4 @@ /** @flow */ | ||
execute(nested: boolean = false) { | ||
if (nested) { | ||
return this._manager.nestQuery(this).then(([result]) => result) | ||
} else { | ||
return this._manager.query(this).then(([result]) => result) | ||
} | ||
execute() { | ||
return this._manager.query(this).then(([result]) => result) | ||
} | ||
@@ -34,0 +30,0 @@ } |
@@ -12,8 +12,4 @@ /** @flow */ | ||
execute(nested: boolean = false) { | ||
if (nested) { | ||
return this._manager.nestQuery(this).then(([result]) => result) | ||
} else { | ||
return this._manager.query(this).then(([result]) => result) | ||
} | ||
execute() { | ||
return this._manager.query(this).then(([result]) => result) | ||
} | ||
@@ -20,0 +16,0 @@ } |
@@ -38,5 +38,9 @@ /** @flow */ | ||
if (nested) { | ||
return this._manager.nestQuery(this).then(([result]) => result) | ||
return this._manager.nestQuery(this).then( | ||
([result]) => result | ||
) | ||
} else { | ||
return this._manager.query(this).then(([result]) => result) | ||
return this._manager.query(this).then( | ||
([result]) => result | ||
) | ||
} | ||
@@ -43,0 +47,0 @@ } |
@@ -22,8 +22,4 @@ /** @flow */ | ||
execute(nested: boolean = false) { | ||
if (nested) { | ||
return this._manager.nestQuery(this).then(([result]) => result) | ||
} else { | ||
return this._manager.query(this).then(([result]) => result) | ||
} | ||
execute() { | ||
return this._manager.query(this).then(([result]) => result) | ||
} | ||
@@ -30,0 +26,0 @@ } |
@@ -29,4 +29,9 @@ /** @flow */ | ||
await user.save() | ||
try { | ||
await manager.startQuery().select().from('users').execute() | ||
} catch (err) { | ||
// Should be wrapped | ||
} | ||
}) | ||
}) | ||
}) |
@@ -128,3 +128,6 @@ /** @flow */ | ||
if (!queries[sql]) { | ||
conn.writeOk(0) | ||
conn.writeError({ | ||
message: 'Wrong query', | ||
code: 8888 | ||
}) | ||
return | ||
@@ -131,0 +134,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
740028
4992