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

add support for raw query streaming #289

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
38 changes: 24 additions & 14 deletions lib/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -897,29 +897,39 @@ module.exports = (function() {

if(_.isUndefined(connection)) {
return spawnConnection(connectionName, __STREAM__);
} else {
}
else {
__STREAM__(connection);
}

function __STREAM__(connection, cb) {

var connectionObject = connections[connectionName];
var collection = connectionObject.collections[collectionName];
var tableName = collectionName;
var query;
if(options.where
&& options.where.id !== undefined
&& typeof options.where.id === 'string'
&& /^select[^]*from[^]*/i.test(options.where.id) ) query = options.where.id;
else {

// Build find query
var schema = connectionObject.schema;
var _query;
var connectionObject = connections[connectionName];
var collection = connectionObject.collections[collectionName];
var tableName = collectionName;
var _query;

var sequel = new Sequel(schema, sqlOptions);
// Build find query
var schema = connectionObject.schema;

// Build a query for the specific query strategy
try {
_query = sequel.find(collectionName, options);
} catch(e) {
return cb(e);
var sequel = new Sequel(schema, sqlOptions);

// Build a query for the specific query strategy
try {
_query = sequel.find(collectionName, options);
}
catch(e) {
return cb(e);
}
query = _query.query[0];
}
var query = _query.query[0];

// Run query
log('MySQL.stream: ', query);
Expand Down