-
Notifications
You must be signed in to change notification settings - Fork 182
provide database column default values via Loopback model description #54
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
Conversation
|
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
|
Would you please add some test cases? |
|
@raymondfeng, no problem, but it'll take some time, because I'm not familiar with test-suite, my bad... |
|
BTW, this feature can be possibly ported to other connectors too. |
|
yeah, I know that :) |
|
@raymondfeng, just added basic tests for this PR. If it's not enough, please advice more test-cases to be considered. |
|
Great, maybe two more tests:
|
|
Okay. Will do it tomorrow! Way too late over here now. |
|
@raymondfeng, just added more tests. |
|
this PR now longer depends on #51. All tests are passing correctly. |
|
Well, It was a headlong verdict about @aars's fix replacement. :) I'm not yet sure how to run only partial tests, so here is the command line that I was using: on your master branch I have the following debug output in 'can be declared in short form' testcase: (note two empty parameters!) And with @aar's patch applied, this query becomes: It seems to me, that it happens if new object is saved and it's fields are not initialised. So, it seems, we need to invent another approach to handle undefined values. Please, let me know, if any of my thoughts are correct. |
|
Seems, this is the way out. All previously failing tests passed! |
1.4.0 * Remove the usage of `CREATE SCHEMA IF NOT EXISTS' for compatibility (Raymond Feng) * one-line fix for #51 (Andrey Loukhnov) * basic tests for PR #53 (Andrey Loukhnov) * basic tests for PR #54 (Andrey Loukhnov) * provide database column default values via Loopback model description (Andrey Loukhnov) * autocreate schema if it does not exist during migration/update (Andrey Loukhnov) * Use connection pooling from the driver (Raymond Feng)
This PR allows to define the default value for a field by the means of database server. It is especially useful when the default value is calculated by a stored procedure.
Example usage is as follows:
simpleUsage.json
Another, a more complex usecase:
myModel.json
I quite agree that in many cases the same behaviour can be achieved by Loopback hooks, but still there are cases exist where default value is calculated by custom stored procedure on the DB side.
Feel free to contact me if you need more comments on this PR.