-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Waterline sets unspecified fields to NULL by itself. (Waterline sets type: 'ref'
fields to null
, the base value.)
#4610
Comments
Hi @dilame! It looks like you may have removed some required elements from the initial comment template, without which I can't verify that this post meets our contribution guidelines. To re-open this issue, please copy the template from here, paste it at the beginning of your initial comment, and follow the instructions in the text. Then post a new comment (e.g. "ok, fixed!") so that I know to go back and check. Sorry to be a hassle, but following these instructions ensures that we can help you in the best way possible and keep the Sails project running smoothly. *If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact inquiries@sailsjs.com |
@dilame This is the expected behavior because |
What shoud i do if i want my database to decide what value to put in the field? createdAt timestamp with time zone default now() I definitely need this field filled on RDBMS layer, so i faithfully don't specify it in |
@dilame Good question! Sails is an opinionated framework, and Waterline is an opinionated ORM. Waterline is only concerned with the logical layer of your data model. Why? Default literals set at the physical layer (in the database) do not always translate neatly to JavaScript R-values, and thinking about business processes and intermediate data with physical-layer data types instead of JavaScript types has been a major mistake I've made too many times to count. I got sick of it. Consider the possibilities: Should your app consider a "TIMESTAMP" from MySQL a string? Or a number? Or should it try to build a Date instance, mixing in convoluted UTC offset information? More importantly, what business value does spending time on that problem even provide? In my experience, it's essentially just a huge time-suck. But you can't ignore logical datatypes either-- because that causes its own set of problems. For example, what happens if you try to call Sails ≥1.0 and Waterline ≥0.13 aim to eliminate those kinds of problems by providing simple, opinionated tools for working with data using logical, JavaScript-compatible (and therefore also browser-compatible) data types. The data type system in Waterline isn't optimized for variations in programming style, it's about conventions. But I know from experience that it is flexible enough to support the data model of every app I've ever worked on. I hope this makes sense-- and please let us know what you think if you get the opportunity to try out Waterline's logical data types in an app! PS. Unfortunately, Waterline won't be able to automatically pick perfectly-matched romantic partners until v3.0 🏩 |
type: 'ref'
fields to null
, the base value.)
Hey @dilame , we're moving all the Waterline issues to the main Sails repo (balderdashy/sails). Feel free to update this case as needed. We appreciate all the info so far. I see a response to this case - feel free to update us if the issue is ongoing. Thank you! |
I have the same issue, in my Database I have a default value |
The temporary solution was to deactivate explicit_defaults_for_timestamp from MySql
|
Hey @hassench, glad you found something that works for you. |
I am still sure - such waterline behavior is the abuse of authority, not opinion. The database is the priority - the client code working with the database is secondary. You should not need to change your database just for waterline quirks. |
Thanks for your feedback @dilame. Waterline is opinionated, and as you might expect we didn't make these decisions lightly. Here's how we reached the logical data types that are in Waterline today: https://docs.google.com/spreadsheets/d/1whV739iW6O9SxRZLCIe2lpvuAUqm-ie7j7tn_Pjir3s/edit?usp=sharing |
I have a model
If i do
I get
createdAt
field NULL in my database. But i have DEFAULTS TO on that field, and i want database to fill createdAt by itself. I think waterline is taking on too much.The text was updated successfully, but these errors were encountered: