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

Problems with unique constraint #9

Open
KSDaemon opened this issue Mar 16, 2016 · 0 comments
Open

Problems with unique constraint #9

KSDaemon opened this issue Mar 16, 2016 · 0 comments

Comments

@KSDaemon
Copy link

Hi! I faced a problem with unique constraint check.
In User model:

    attributes: {
        login: {
            type              : 'string',
            size              : 64,
            unique            : true,
            notEmpty          : true,
            alphanumericdashed: true
        }

Then in controller action (passing a login, that allready exists in table in db):

        User.create(req.params.all())
            .exec(function (err, user) {
               ...
             });

Doesn't get to exec callback function with errors:

Error (E_VALIDATION) :: 0 attributes are invalid
    at new WLError (/Users/kostik/Projects/Home-Genie-Sails/node_modules/sails-hook-validation/node_modules/waterline/lib/waterline/error/WLError.js:26:15)
    at Object.module.exports.patch (/Users/kostik/Projects/Home-Genie-Sails/node_modules/sails-hook-validation/lib/WLValidationError.js:8:13)
    at /Users/kostik/Projects/Home-Genie-Sails/node_modules/sails-hook-validation/lib/create.js:66:48
    at /Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/lib/waterline/query/dql/create.js:223:14
    at wrapper (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/node_modules/lodash/index.js:3592:19)
    at applyInOriginalCtx (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/lib/waterline/utils/normalize.js:417:80)
    at module.exports.callback.wrappedCallback (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/lib/waterline/utils/normalize.js:331:16)
    at module.exports.callback.callback.error (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:42:31)
    at module.exports._switch (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/node_modules/switchback/lib/factory.js:56:28)
    at afterwards (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/lib/waterline/adapter/dql.js:87:16)
    at wrapper (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/node_modules/lodash/index.js:3592:19)
    at applyInOriginalCtx (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/lib/waterline/utils/normalize.js:417:80)
    at module.exports.callback.wrappedCallback (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/lib/waterline/utils/normalize.js:331:16)
    at module.exports.callback.callback.error (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:42:31)
    at module.exports._switch (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline/node_modules/switchback/lib/factory.js:56:28)
    at AdapterError.wrap (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline-sqlite3/dist/error.js:33:45)
    at tryCatcher (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline-sqlite3/node_modules/knex/node_modules/bluebird/js/main/util.js:26:23)
    at Promise.module.exports.Promise._settlePromiseFromHandler (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline-sqlite3/node_modules/knex/node_modules/bluebird/js/main/promise.js:507:31)
    at Promise.module.exports.Promise._settlePromiseAt (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline-sqlite3/node_modules/knex/node_modules/bluebird/js/main/promise.js:581:18)
    at Promise.module.exports.Promise._settlePromises (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline-sqlite3/node_modules/knex/node_modules/bluebird/js/main/promise.js:697:14)
    at Async._drainQueue (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline-sqlite3/node_modules/knex/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline-sqlite3/node_modules/knex/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.__dirname.Async.drainQueues [as _onImmediate] (/Users/kostik/Projects/Home-Genie-Sails/node_modules/waterline-sqlite3/node_modules/knex/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

Details:  Invalid attributes sent to undefined:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant