From ad3e1e8d8a7709c8535bb079e01318629d1d7b13 Mon Sep 17 00:00:00 2001 From: Agnes Lin Date: Thu, 16 Jan 2020 14:46:54 -0500 Subject: [PATCH] add warning strict cannot be false with SQL dbs this is only for LB4 --- docs/definition-language.md | 4 ++-- lib/datasource.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/definition-language.md b/docs/definition-language.md index 1b4dd2e2..c0de36b1 100644 --- a/docs/definition-language.md +++ b/docs/definition-language.md @@ -178,11 +178,11 @@ There are a set of options to control the model definition. - strict: - true: Only properties defined in the model are accepted. Use this - mode if you want to make sure only predefined properties are accepted. + mode if you want to make sure only predefined properties are accepted. Relational databases only support this setting. - false: The model will be an open model. All properties are accepted, including the ones that not predefined with the model. This mode is useful if the mobile application just wants to store free form JSON data to - a schema-less database such as MongoDB. + a schema-less database such as MongoDB. For relational databases, the value will be converted back to true. - undefined: Default to false unless the data source is backed by a relational database such as Oracle or MySQL. diff --git a/lib/datasource.js b/lib/datasource.js index 2500677a..da40aec8 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -826,7 +826,9 @@ DataSource.prototype.define = function defineClass(className, properties, settin settings.strict = true; } if (settings.strict === false) { - settings.strict = 'throw'; + console.warn("WARNING: relational database doesn't support {strict: false} mode." + + ` {strict: true} mode will be set for model ${className} instead.`); + settings.strict = true; } }