appscot / sails-orientdb

OrientDB adapter for Waterline / Sails.js ORM
MIT License
25 stars 23 forks source link

Create Test_edge_creation #119

Closed tommykennedy closed 9 years ago

tommykennedy commented 9 years ago

Hi Dario

I hope this test is attached now

Tom

EDIT: adds failing test for #116

dmarcelino commented 9 years ago

Hey @tommykennedy, made few inline comments. Because the file doesn't end with .js it didn't run. Please fix the aforementioned things and commit to the same branch. Cheers

tommykennedy commented 9 years ago

I have updated the file with your instructions and appended .js to the filename.

dmarcelino commented 9 years ago

So it seems your test is actually passing (https://travis-ci.org/appscot/sails-orientdb/jobs/70070905#L1265):

  Bug #116: Found class name null
    Create answer
  ✓ should add answer and create edge answered from answer to questions (38ms)

Can it be that your model definition is slightly different from the one used in the test?

tommykennedy commented 9 years ago

I ran the test on my machine and it fails it with the error.

Im using the following configuration below.

OrientDB Server v2.0.1

"name": "sails-orientdb", "version": "0.10.55",

dmarcelino commented 9 years ago

Can you try upgrading your OrientDB server to v2.0.12 to dismiss any potential OrientDB change?

The only thing that changed in master branch after v0.10.55 was updating dependencies, you can try that locally... but it's unlikely it would cause this issue.

tommykennedy commented 9 years ago

I upgraded to 2.0.12 and deleted sails-orientdb and reinstalled it npm install sails-orientdb. The exact output I get is.

3) Bug #116: Found class name null Create answer should add answer and create edge answered from answer to questions: [Error (E_UNKNOWN) Encountered an unexpected error] Details: OrientDB.RequestError: Found class name null or empty

Error (E_UNKNOWN) :: Encountered an unexpected error Error (E_UNKNOWN) :: Encountered an unexpected error OrientDB.RequestError: Found class name null or empty at readableAddChunk (_stream_readable.js:163:16) at Socket.Readable.push (_stream_readable.js:126:10) at TCP.onread (net.js:538:20)

tommykennedy commented 9 years ago

I ran the test script on another machine with Orient 2.0.12 and npm install sails-orientdb. I created the test script in /test/integration-orientdb/bugs and executed npm test.

Same error

Did you use the last updated 116-test_edge_creation.js in the test?

tommykennedy commented 9 years ago

I figured out how to turn debugging on and the output is below. Im not sure why answer gets an @class property within the embedded type. Also why is there another type field with value document. I would have expected this to be in the @type field. E.g { Answer: { '@type': 'd', '@class': '', type: 'document', binary: 'Yes' }

Bug #116: Found class name null sails-orientdb:adapter:debug registerConnection: db=test_bug_116 , connection=test_bug_116 +2ms sails-orientdb:connection:info Connecting to database... +0ms sails-orientdb:edge:debug _getEdgeSides: finding vertexes for: answer_questionquestions_answers +2ms sails-orientdb:edge:debug _getEdgeSides: match found for answer_question: question +0ms sails-orientdb:edge:debug _getEdgeSides: match found for questions_answers: answers +0ms sails-orientdb:edge:info Edge [answer_questionquestions_answers] has changed its tableName to [answered] +0ms sails-orientdb:connection:info Database test_bug_116 not found, will create it. +3ms sails-orientdb:adapter:debug describe: Answer +19ms sails-orientdb:adapter:debug describe: Answer +1ms sails-orientdb:adapter:debug define: Answer +0ms sails-orientdb:adapter:debug describe: Questions +9ms sails-orientdb:adapter:debug describe: Questions +1ms sails-orientdb:adapter:debug define: Questions +0ms sails-orientdb:adapter:debug describe: answer_questionquestions_answers +10ms sails-orientdb:adapter:debug describe: answer_questionquestions_answers +0ms sails-orientdb:adapter:debug define: answer_questionquestionsanswers +0ms sails-orientdb:connection:info All classes created, post processing +10ms Create answer sails-orientdb:document:debug Insert into [Questions] values: [object Object] Inspected object #1___ { question: 'This should work, shouldnt it?', createdAt: Wed Jul 08 2015 21:26:54 GMT+0100 (BST), updatedAt: Wed Jul 08 2015 21:26:54 GMT+0100 (BST) } +9ms sails-orientdb:document:debug Insert result id: { cluster: 12, position: 0 } +1ms sails-orientdb:document:debug Insert into [Answer] values: [object Object] _Inspected object #1_ { Answer: { binary: 'Yes', '@type': 'd' }, createdAt: Wed Jul 08 2015 21:26:54 GMT+0100 (BST), updatedAt: Wed Jul 08 2015 21:26:54 GMT+0100 (BST) } +1ms sails-orientdb:document:debug Insert result id: { cluster: 11, position: 0 } +1ms sails-orientdb:document:debug Update [Answer] with values: [object Object] _Inspected object #1_ { Answer: { '@type': 'd', '@class': '', type: 'document', binary: 'Yes' }, createdAt: Wed Jul 08 2015 21:26:54 GMT+0100 (BST), updatedAt: Wed Jul 08 2015 21:26:54 GMT+0100 (BST), '@rid': '#11:0' } +1ms sails-orientdb:document:debug Update where query: @rid = :param0 +0ms sails-orientdb:document:debug Update params: { param0: { cluster: 11, position: 0 } } +0ms sails-orientdb:document:error Failed to update, error: OrientDB.RequestError: Found class name null or empty _Stack trace #1_ OrientDB.RequestError: Found class name null or empty

tommykennedy commented 9 years ago

Dario

Have you tried running the test script on your local machine? I build passed on travis for me also. Im totally stumped as it has failed on 2 separate machines now.

dmarcelino commented 9 years ago

I was just doing that :), the test passed against OrientDB v2.0.10:

  Bug #116: Found class name null or empty
    Create answer
      ✓ should add answer and create edge answered from answer to questions

Which OS are you using btw? My machine is a Mac while travis runs on linux (not sure which).

tommykennedy commented 9 years ago

Im running Mac OS X Yosemite 10.10.3

My debug output looks strange.

Let me download 2.0.10 and check that.

dmarcelino commented 9 years ago

I'm still on Mavericks but I would be surprised if that was the source of our different results.

Meanwhile I've submitted tommykennedy/sails-orientdb#1 in an attempt to fix the issue. Can you please try it and report back?

tommykennedy commented 9 years ago

Eureka. That fixes it and the edges get created.

There seems to be an extra type property getting added also below {"@type":"document","@version":0,"binary":"yes","type":"document"}

Could it got to do with any global libraries such as an older version of oriento being used?

dmarcelino commented 9 years ago

Good to hear that!

When sails-orientdb retrieves records from OrientDB it gets that metadata. It attempts to clean it where possible though I don't think it's cleaning it for embedded records... It seems the data is being added but it's really just saving what was retrieved.

I've made an improvement to the workaround (10299b119dec684a88f6f5c0fc50d48ab87e1227), please test. Once you merge tommykennedy/sails-orientdb#1 I'll be able to merge this PR.

dmarcelino commented 9 years ago

Thanks @tommykennedy for the report and test!

tommykennedy commented 9 years ago

No problem happy to contribute and I learned a lot to contribute more in the future

Sent from my iPhone

On 10 Jul 2015, at 12:56, Dário notifications@github.com wrote:

Thanks @tommykennedy for the report and test!

— Reply to this email directly or view it on GitHub.