不要怂,就是干,撸起袖子干!

Commit 1ca53a32 by sdepold

refactored error throw in query-generator super class

1 parent e10cb517
Showing with 44 additions and 13 deletions
...@@ -5,14 +5,14 @@ module.exports = (function() { ...@@ -5,14 +5,14 @@ module.exports = (function() {
Attributes should have the format: {attributeName: type, attr2: type2} --> {title: 'VARCHAR(255)'} Attributes should have the format: {attributeName: type, attr2: type2} --> {title: 'VARCHAR(255)'}
*/ */
createTableQuery: function(tableName, attributes, options) { createTableQuery: function(tableName, attributes, options) {
throw new Error('Define the method createTableQuery!') throwMethodUndefined.call('createTableQuery')
}, },
/* /*
Returns a query for dropping a table. Returns a query for dropping a table.
*/ */
dropTableQuery: function(tableName, options) { dropTableQuery: function(tableName, options) {
throw new Error('Define the method dropTableQuery!') throwMethodUndefined.call('dropTableQuery')
}, },
/* /*
...@@ -22,7 +22,7 @@ module.exports = (function() { ...@@ -22,7 +22,7 @@ module.exports = (function() {
- futureTableName: Name of the table after execution. - futureTableName: Name of the table after execution.
*/ */
renameTableQuery: function(originalTableName, futureTableName) { renameTableQuery: function(originalTableName, futureTableName) {
throw new Error('Define the method renameQuery!') throwMethodUndefined.call('renameTableQuery')
}, },
/* /*
...@@ -37,7 +37,7 @@ module.exports = (function() { ...@@ -37,7 +37,7 @@ module.exports = (function() {
- allowNull: Boolean - allowNull: Boolean
*/ */
addColumnQuery: function(tableName, attributes) { addColumnQuery: function(tableName, attributes) {
throw new Error('Define the method addColumnQuery!') throwMethodUndefined.call('addColumnQuery')
}, },
/* /*
...@@ -47,7 +47,7 @@ module.exports = (function() { ...@@ -47,7 +47,7 @@ module.exports = (function() {
- attributeName: Name of the obsolete attribute. - attributeName: Name of the obsolete attribute.
*/ */
removeColumnQuery: function(tableName, attributeName) { removeColumnQuery: function(tableName, attributeName) {
throw new Error('Define the method removeColumnQuery!') throwMethodUndefined.call('removeColumnQuery')
}, },
/* /*
...@@ -62,7 +62,7 @@ module.exports = (function() { ...@@ -62,7 +62,7 @@ module.exports = (function() {
- allowNull: Boolean - allowNull: Boolean
*/ */
changeColumnQuery: function(tableName, attribute) { changeColumnQuery: function(tableName, attribute) {
throw new Error('Define the method modifyColumnQuery!') throwMethodUndefined.call('changeColumnQuery')
}, },
/* /*
...@@ -73,7 +73,7 @@ module.exports = (function() { ...@@ -73,7 +73,7 @@ module.exports = (function() {
- attrNameAfter: The name of the attribute, after renaming. - attrNameAfter: The name of the attribute, after renaming.
*/ */
renameColumnQuery: function(tableName, attrNameBefore, attrNameAfter) { renameColumnQuery: function(tableName, attrNameBefore, attrNameAfter) {
throw new Error('Define the method renameColumnQuery!') throwMethodUndefined.call('renameColumnQuery')
}, },
/* /*
...@@ -90,14 +90,14 @@ module.exports = (function() { ...@@ -90,14 +90,14 @@ module.exports = (function() {
- offset -> An offset value to start from. Only useable with limit! - offset -> An offset value to start from. Only useable with limit!
*/ */
selectQuery: function(tableName, options) { selectQuery: function(tableName, options) {
throw new Error('Define the method selectQuery!') throwMethodUndefined.call('selectQuery')
}, },
/* /*
Returns an insert into command. Parameters: table name + hash of attribute-value-pairs. Returns an insert into command. Parameters: table name + hash of attribute-value-pairs.
*/ */
insertQuery: function(tableName, attrValueHash) { insertQuery: function(tableName, attrValueHash) {
throw new Error('Define the method insertQuery!') throwMethodUndefined.call('insertQuery')
}, },
/* /*
...@@ -111,7 +111,7 @@ module.exports = (function() { ...@@ -111,7 +111,7 @@ module.exports = (function() {
If you use a string, you have to escape it on your own. If you use a string, you have to escape it on your own.
*/ */
updateQuery: function(tableName, values, where) { updateQuery: function(tableName, values, where) {
throw new Error('Define the method updateQuery!') throwMethodUndefined.call('updateQuery')
}, },
/* /*
...@@ -126,14 +126,41 @@ module.exports = (function() { ...@@ -126,14 +126,41 @@ module.exports = (function() {
- limit -> Maximaum count of lines to delete - limit -> Maximaum count of lines to delete
*/ */
deleteQuery: function(tableName, where, options) { deleteQuery: function(tableName, where, options) {
throw new Error('Define the method deleteQuery!') throwMethodUndefined.call('deleteQuery')
},
/*
Returns an add index query.
Parameters:
- tableName -> Name of an existing table.
- attributes:
An array of attributes as string or as hash.
If the attribute is a hash, it must have the following content:
- attribute: The name of the attribute/column
- length: An integer. Optional
- order: 'ASC' or 'DESC'. Optional
- options:
- indicesType: UNIQUE|FULLTEXT|SPATIAL
- indexName: The name of the index. Default is <tableName>_<attrName1>_<attrName2>
- parser
*/
addIndexQuery: function(tableName, attributes, options) {
throwMethodUndefined.call('addIndexQuery')
},
showIndexQuery: function(tableName, options) {
throwMethodUndefined.call('showIndexQuery')
},
removeIndexQuery: function(tableName, options) {
throwMethodUndefined.call('removeIndexQuery')
}, },
/* /*
Takes something and transforms it into values of a where condition. Takes something and transforms it into values of a where condition.
*/ */
getWhereConditions: function(smth) { getWhereConditions: function(smth) {
throw new Error('Define the method getWhereConditions!') throwMethodUndefined.call('getWhereConditions')
}, },
/* /*
...@@ -141,10 +168,14 @@ module.exports = (function() { ...@@ -141,10 +168,14 @@ module.exports = (function() {
The values are transformed by the relevant datatype. The values are transformed by the relevant datatype.
*/ */
hashToWhereConditions: function(hash) { hashToWhereConditions: function(hash) {
throw new Error('Define the method hashToWhereConditions!') throwMethodUndefined.call('hashToWhereConditions')
} }
} }
var throwMethodUndefined = function(methodName) {
throw new Error('The method "' + methodName + '" was not defined!')
}
return QueryGenerator return QueryGenerator
})() })()
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!