-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
141 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
var Promise = require('bluebird'); | ||
describe("Database API - Live Query ", function () { | ||
|
||
this.timeout(20000); | ||
before(function () { | ||
return CREATE_TEST_DB(this, 'testdb_live_query') | ||
.bind(this) | ||
|
||
.then(function () { | ||
|
||
this.db = USE_TOKEN_DB("testdb_live_query"); | ||
return this.db.open(); | ||
}).then(function () { | ||
this.writeDB = USE_TOKEN_DB("testdb_live_query"); | ||
return this.writeDB.open(); | ||
}) | ||
.then(function () { | ||
return this.db.class.create('Test', 'V'); | ||
}) | ||
.then(function (item) { | ||
this.class = item; | ||
return this.class.property.create([ | ||
{ | ||
name: 'name', | ||
type: 'String' | ||
}, | ||
{ | ||
name: 'creation', | ||
type: 'DateTime' | ||
} | ||
]); | ||
}) | ||
.then(function () { | ||
return this.class.create([ | ||
{ | ||
name: 'a', | ||
creation: '2001-01-01 00:00:01' | ||
}, | ||
{ | ||
name: 'b', | ||
creation: '2001-01-02 12:00:01' | ||
}, | ||
{ | ||
name: 'c', | ||
creation: '2009-01-01 00:12:01' | ||
}, | ||
{ | ||
name: 'd', | ||
creation: '2014-09-01 00:01:01' | ||
}, | ||
{ | ||
name: 'e', | ||
creation: '2014-09-01 00:24:01' | ||
} | ||
]) | ||
}); | ||
}); | ||
after(function () { | ||
return DELETE_TEST_DB('testdb_live_query'); | ||
}); | ||
|
||
|
||
it('should trigger live query', function (done) { | ||
|
||
var TOTAL = 2; | ||
var record; | ||
var count = 0; | ||
|
||
this.db.liveQuery("LIVE SELECT FROM Test").on('live-insert', function (data) { | ||
count++; | ||
if (count === TOTAL) { | ||
data.content.name.should.eql('a'); | ||
done(); | ||
} | ||
}); | ||
var self = this; | ||
setTimeout(function () { | ||
var promises = []; | ||
for (var i = 0; i < TOTAL; i++) { | ||
promises.push(self.db.create("VERTEX", "Test") | ||
.set( | ||
{ | ||
name: 'a', | ||
creation: '2001-01-01 00:00:01' | ||
}) | ||
.one()) | ||
} | ||
Promise.all(promises).then(function (rec) { | ||
}) | ||
}, 1000); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f86f13a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi maggiolo00,
saw your LiveQuery fix (guess in response to #36, so thanks!) in this branch and tried it out in 2.1.13. As this version is using protocol 32 the change in line 376 of connection.js unfortunately fails. I hard-coded
protocol28
for the sake of testing, since this directory was available. Good news is that the error "Unsupported operation status: 6" is issued less often than before, but could still be provoked by emitting 3 x 20 simple updates ("update #22:6 set name = 'lastcontact'"
) to the same record within 2 seconds from Studio (BATCH run) and listening to alive-update
-event. The error now thrown has updated line numbers, of course:Unhandled rejection OrientDB.ProtocolError: Unsupported operation status: 6 at Connection.process (/.../node_modules/orientjs/lib/transport/binary/connection.js:414:23) at Connection.handleSocketData (/.../node_modules/orientjs/lib/transport/binary/connection.js:284:17) at emitOne (events.js:90:13) at Socket.emit (events.js:182:7) at readableAddChunk (_stream_readable.js:153:18) at Socket.Readable.push (_stream_readable.js:111:10) at TCP.onread (net.js:529:20)
Any ideas?
f86f13a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @kaYcee
i've tried this fix against the 2.2-beta. I will backport it to 2.1.x in the next days.