fix: warn about strict cannot be false with relational dbs#1817
Conversation
786a131 to
50f8b97
Compare
|
Looks mostly good so far. Is it possible to write a test to verify the behavior by spying on
Using Can you please verify that your fix is covering all different ways we have for defining a model? Most importantly, is the warning triggered when models are created before they are attached to a datasource? That's what we are doing in LoopBack 3 applications. Here is the code creating a new model class via And here we are attaching a model to a datasource - I think that's |
|
The reason why I don't have a test for the changes is because I am thinking to add them to lb4 tests since we can easily test them on real DBs. Thoughts?
Good point, I didn't consider is before. I just chased through and found where we check I did some debug. I didn't create a LB3 app and check it with relational connectors( I don't know how 🙈). I used LB4 code and MySQL as dataSource (I think it's fine since both of them use connectors and Juggler?). It shows in LB4 that it creates models with DataSource.prototype.createModel, |
| } | ||
| if (settings.strict === false) { | ||
| settings.strict = 'throw'; | ||
| console.warn('WARNING: relational database doesn\'t support {strict: false} mode.' + |
There was a problem hiding this comment.
Use double quotes to avoid escaping: "WARNING: relational database doesn't support {strict: false} mode."
50f8b97 to
9dbcd12
Compare
AFAIK, LB3 uses a different code path for creating models. Creating a LB3 app is easy, see https://loopback.io/lb3/getting-started. You can also use our Coffee Shop example https://github.com/strongloop/loopback-getting-started. As for adding a relational connector, just install the connector and change the datasource configuration accordingly. In LB3, datasources are configured in AFAICT, the Coffee Shop example is already using MySQL to store the data! I think it should be enough to On the other hand, considering that LB3 is in LTS, maybe it's enough to implement the warning for LB4 only? |
You're right. I ran the coffee shop example with MySQL. The change only affects LB4. I think LB3 uses
I think it's fair to just have the warning and tests for LB4. I will add them once the change gets released. |
this is only for LB4
9dbcd12 to
ad3e1e8
Compare
|
@slnode test please |
|
@slnode test please |
Fixes loopbackio/loopback-next#4042
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm testpasses on your machine