Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 94 - Solution to Issue #94 #95

Merged
merged 3 commits into from
Feb 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/databasemetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ function DatabaseMetaData(dbm) {
* @returns {ResultSet} Via callback: a ResultSet object in which each row is a schema description
*/
DatabaseMetaData.prototype.getSchemas = function(catalog, schemaPattern, callback) {
if(_.isFunction(catalog)) {
callback = catalog;
catalog = null;
} else if(_.isFunction(schemaPattern)) {
callback = schemaPattern;
schemaPattern = null;
}
if(_.isFunction(catalog)) {
callback = catalog;
catalog = null;
} else if(_.isFunction(schemaPattern)) {
callback = schemaPattern;
schemaPattern = null;
}

var validParams = (
(_.isNull(catalog) || _.isUndefined(catalog) || _.isString(catalog)) &&
Expand Down
50 changes: 24 additions & 26 deletions lib/resultset.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,35 +97,33 @@ ResultSet.prototype.toObjectIter = function(callback) {
rows: {
next: function() {
var nextRow = self._rs.nextSync();
if (nextRow) {
var result = {};
var type = 'String'; // Default to getStringSync getter.

// loop through each column
_.each(_.range(1, colcount + 1), function(i) {
var cmd = colsmetadata[i-1];

if (self._types[cmd.type]) {
type = self._types[cmd.type];
} else {
type = 'String'; // Default to getStringSync getter.
}
if (! nextRow) {
return {done: true};
}

if (type === 'Date' || type === 'Time' || type === 'Timestamp') {
if (self._rs['get' + type + 'Sync'](i)) {
result[cmd.label] = self._rs['get' + type + 'Sync'](i).toString();
} else { // if date is empty, it should be null
result[cmd.label] = null;
}
} else {
result[cmd.label] = self._rs['get' + type + 'Sync'](i);
var result = {};

// loop through each column
_.each(_.range(1, colcount + 1), function(i) {
var cmd = colsmetadata[i-1];
var type = self._types[cmd.type] || 'String';
var getter = 'get' + type + 'Sync';

if (type === 'Date' || type === 'Time' || type === 'Timestamp') {
var dateVal = self._rs[getter](i);
result[cmd.label] = dateVal ? dateVal.toString() : null;
} else {
// If the column is an integer and is null, set result to null and continue
if (type === 'Int' && _.isNull(self._rs.getObjectSync(i))) {
result[cmd.label] = null;
return;
}
});

return {value: result, done: false};
} else {
return {done: true};
}
result[cmd.label] = self._rs[getter](i);
}
});

return {value: result, done: false};
}
}
});
Expand Down
8 changes: 4 additions & 4 deletions lib/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ Statement.prototype.setQueryTimeout = function(seconds, callback) {

Statement.prototype.getGeneratedKeys = function(callback) {
this._s.getGeneratedKeys(function(err, resultset) {
if(err) {
return callback(err);
}
if(err) {
return callback(err);
}
return callback(null, new ResultSet(resultset));
});
});
};

jinst.events.once('initialized', function onInitialized() {
Expand Down