diff --git a/lib/persisted-model.js b/lib/persisted-model.js index 6e9d07e5..13ca19c4 100644 --- a/lib/persisted-model.js +++ b/lib/persisted-model.js @@ -7,6 +7,7 @@ var registry = require('./registry'); var runtime = require('./runtime'); var assert = require('assert'); var async = require('async'); +var deprecated = require('depd')('loopback'); /** * Extends Model with basic query and CRUD support. @@ -1041,6 +1042,15 @@ PersistedModel.enableChangeTracking = function() { assert(this.dataSource, 'Cannot enableChangeTracking(): ' + this.modelName + ' is not attached to a dataSource'); + var idName = this.getIdName(); + var idProp = this.definition.properties[idName]; + var idType = idProp && idProp.type; + var idDefn = idProp && idProp.defaultFn; + if (idType !== String || !(idDefn === 'uuid' || idDefn === 'guid')) { + deprecated('The model ' + this.modelName + ' is tracking changes, ' + + 'which requries a string id with GUID/UUID default value.'); + } + Change.attachTo(this.dataSource); Change.getCheckpointModel().attachTo(this.dataSource); diff --git a/package.json b/package.json index 198a29ce..b0196f31 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "canonical-json": "0.0.4", "continuation-local-storage": "~3.1.1", "debug": "~2.0.0", + "depd": "^1.0.0", "ejs": "~1.0.0", "express": "^4.10.2", "inflection": "~1.4.2", @@ -52,7 +53,7 @@ "underscore.string": "~2.3.3" }, "peerDependencies": { - "loopback-datasource-juggler": "^2.17.0" + "loopback-datasource-juggler": "^2.19.0" }, "devDependencies": { "browserify": "~4.2.3", @@ -79,7 +80,7 @@ "karma-phantomjs-launcher": "~0.1.4", "karma-script-launcher": "~0.1.0", "loopback-boot": "^1.1.0", - "loopback-datasource-juggler": "^2.17.0", + "loopback-datasource-juggler": "^2.19.0", "loopback-testing": "~0.2.0", "mocha": "~1.21.4", "strong-task-emitter": "0.0.x", @@ -94,6 +95,7 @@ "./lib/server-app.js": "./lib/browser-express.js", "connect": false, "nodemailer": false, + "depd": "loopback-datasource-juggler/lib/browser.depd.js", "bcrypt": false }, "license": {