KSDaemon/sails-hook-sequelize

SequelizeUniqueConstraintError: Validation error

rash240719 opened this issue · 3 comments

Sails throws this when running my mocha tests (using npm start):

Error: Callback was already called.
    at node_modules/sails/node_modules/async/dist/async.js:903:32
    at node_modules/sails/lib/app/private/loadHooks.js:218:46
    at node_modules/async-listener/glue.js:188:31
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
SequelizeUniqueConstraintError: Validation error
    at Query.formatError (node_modules/sequelize/lib/dialects/postgres/query.js:325:18)
    at Result.query.on.err (node_modules/sequelize/lib/dialects/postgres/query.js:93:21)
    at Result.Query.handleError (node_modules/pg/lib/query.js:163:8)
    at Client.<anonymous> (node_modules/pg/lib/client.js:188:26)
    at Socket.<anonymous> (node_modules/pg/lib/connection.js:133:12)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread [as _originalOnread] (net.js:594:20)
    at TCP.onread (node_modules/async-listener/glue.js:188:31)

These tests are pretty much empty since it's a brand new project. The only test is this:

require('../../bootstrap.test');

describe('RootService', function () {
  it('Basic test',
    function (done) {
      assert.equal(0, 0);
      done();
    });
});

Though running the app itself, using npm start works, but I've not yet tried to do anything once lifted, so I don't know if something won't work.

The only model so far is Root.js, which as you can tell is unused:

module.exports = {

  attributes: {
    description: {
      type: Sequelize.STRING,
      allowNull: false
    }
  },

  associations: function () {
  },

  options: {
    tableName: 'Root',
    classMethods: {},
    instanceMethods: {},
    hooks: {}
  }
};

Thanks in advance

Hi @rash240719!
Well... There are some unanswered questions.... What is your sails config? what is your hook config? What type of migration do you use? ....
Please, have a look at test folder. There are tests for v0.12, v1.0 sails versions, that works as expected.

Hi
I'm sorry for such late a reply.

.sailsrc

{
  "hooks": {
      "blueprints": false,
      "orm": false,
      "pubsub": false
  }
}

No migrations so far. I would start using migrations until I am able of successfully setting up sequelize in my project. Thanks, I'll sure have a look at that.

@rash240719 Have you resolved your issue? If not — please create a test repo, producing such problem, so i (or may be someone else) can help