faustinoaq changed the topic of #amber to: Welcome to Amber Framework community! | https://amberframework.org | Developer happiness, productivity and bare metal performance | GH: https://github.com/amberframework | Docs: https://docs.amberframework.org | Gitter: https://gitter.im/amberframework/amber | IRC Logger: https://irclog.whitequark.org/amber | Amber::Server.start
<FromGitter> <Blacksmoke16> because it its not really type safe and it shouldnt be an ORMs responsibility to convert params into a model
<FromGitter> <Nicolab> you prefer named arguments?
<FromGitter> <Blacksmoke16> i prefer defining an explicit constructor like you would for a normal classs
<FromGitter> <Nicolab> `Review.create(name: "two", published: false)`
<FromGitter> <Nicolab> ok
<FromGitter> <Blacksmoke16> thats also fine because internally it gets passes to `.new`
<FromGitter> <Nicolab> ok thanks
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5e1910d90e65654fa0c0b913]
<FromGitter> <Blacksmoke16> something like that
<FromGitter> <Nicolab> looks nice
<FromGitter> <Blacksmoke16> would be a better experience than automagically defining initializers behind the scene like it does now
<FromGitter> <Nicolab> surely
<FromGitter> <Nicolab> I think in this case, the creation of a resource must validate everything. However, the updates are partial. So I have to list each parameter right?
<FromGitter> <Blacksmoke16> how are you handling it now?
<FromGitter> <Nicolab> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5e19129c65540a529af617ee]
<FromGitter> <Nicolab> In Go it's about the same. when I do PHP (several years ago lol), same (example with the validator of Laravel)
<FromGitter> <Blacksmoke16> more so mean on the amber side of things
<FromGitter> <Nicolab> It's comfortable
<FromGitter> <Blacksmoke16> like by partial update i assume you are talking about like sending `{"lang":"fr"}` and it just updating that one column
<FromGitter> <Nicolab> yes
<FromGitter> <Nicolab> or another
<FromGitter> <Blacksmoke16> yea how do you handle that?
<FromGitter> <Nicolab> In Crystal I don't know yet. With the other languages, I simply update as I will with the native driver, except that the ORM (or ODM) or the validator checks the data before
<FromGitter> <Blacksmoke16> would be easier if you send the whole body representing the user
<FromGitter> <Nicolab> I think it's an unnecessary constraint
<FromGitter> <Nicolab> Especially for the backend of a mobile app. In addition it requires larger treatments, just for one or two fields
<FromGitter> <Blacksmoke16> would basically have to have a way to support setting only xyz fields
<FromGitter> <Blacksmoke16> since you cant call a setter based on a string value it's tricky
<FromGitter> <Nicolab> ok
<FromGitter> <Blacksmoke16> have to be some macro that accepts a field and value and uses a case to set it
<FromGitter> <Blacksmoke16> one way would maybe adding some `merge` method that accepts `self`
<FromGitter> <Blacksmoke16> like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5e191548c6897e1bc610587b]
<FromGitter> <Blacksmoke16> ```def merge(other : self) : self ⏎ if l = other.lang? ⏎ @lang = l ⏎ end ⏎ end``` [https://gitter.im/amberframework/amber?at=5e1915771cf5106b35fd31a3]
<FromGitter> <Nicolab> It's a solution
<FromGitter> <Blacksmoke16> something like that
<FromGitter> <Blacksmoke16> be pretty easy to make it a module and can just include it
<FromGitter> <Blacksmoke16> `include Mergable` or
<FromGitter> <Blacksmoke16> naming tbd
<FromGitter> <Blacksmoke16> esp with that PR, as it would define all the fields as nilable under the hood, so would be able to new one up with just one property set
<FromGitter> <Blacksmoke16> wouldnt be able to save it ofc tho
<FromGitter> <Nicolab> it's the extra request that is annoying ⏎ ⏎ Maybe there is an ORM or an active record lib that manages the partial? ⏎ ⏎ Crecto works like that too? [https://gitter.im/amberframework/amber?at=5e1915e4b990d50d8190467c]
<FromGitter> <Blacksmoke16> how else would you do it?
<FromGitter> <Blacksmoke16> w/o looking up the record
<FromGitter> <Nicolab> in crystal I don't know, I've been discovering the echo system for a week
<FromGitter> <Nicolab> in the end it is a SQL UPDATE query
<FromGitter> <Blacksmoke16> maybe thats the answer then
<FromGitter> <Blacksmoke16> define some method that just builds out an update query based on the params
<FromGitter> <Blacksmoke16> and then execs it
<FromGitter> <Nicolab> yes I think also
<FromGitter> <Blacksmoke16> could have it accept `self` as well to keep it more OOP
<FromGitter> <Nicolab> Yes. I made a lib a long time ago that generated the query. With whitelist of table fields, other fields of the object were ignored
<FromGitter> <Nicolab> Seeing how much time I waste looking for, I think I would be quicker to do a few things like that (a kind of helper)
<FromGitter> <Nicolab> It only takes correspondence with the keys we pass to it
<FromGitter> <Blacksmoke16> would ofc want to run validations on the values before running the update
<FromGitter> <Blacksmoke16> since its a raw query, nothing preventing you from messing it up
<FromGitter> <Nicolab> Of course :)
<FromGitter> <Nicolab> All that's left to do is. Thanks
<FromGitter> <Blacksmoke16> np
<FromGitter> <Nicolab> Is it possible to make a raw query with Granite?
<FromGitter> <Blacksmoke16> Yes
<FromGitter> <Nicolab> Yea! I searched the code, I can't find
<FromGitter> <Blacksmoke16> Look in transactions
<FromGitter> <Blacksmoke16> At the bottom
<FromGitter> <Nicolab> ok thanks
<FromGitter> <Blacksmoke16> Is like exec
<FromGitter> <Nicolab> great
raz has quit [Ping timeout: 250 seconds]
raz has joined #amber
raz has quit [Changing host]
raz has joined #amber
feepbot has quit [Ping timeout: 258 seconds]
feepbot has joined #amber
_whitelogger has joined #amber
_whitelogger has joined #amber