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
_whitelogger has joined #amber
^raz^ has joined #amber
raz has quit [*.net *.split]
feepbot has quit [Ping timeout: 252 seconds]
feepbot has joined #amber
<FromGitter> <hfjallemark> Any ideas what I am doing wrong here, can't seem to get JSON serialisation to work with my Granite model: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ It still includes the `updated_at` field and uses `created_at` instead of `posted` [https://gitter.im/amberframework/amber?at=5bd30f866e5a401c2dd30bf7]
<FromGitter> <hfjallemark> It actually works on the other fields
<FromGitter> <hfjallemark> Just not the created_at/updated_at
Jenz has joined #amber
<Jenz> Anyone here?
<Jenz> I ask, because Im on IRC, hence I won't get notified if anyone tags me with an anwer on gitter when Im not on
<Jenz> Though when I see how well this chan is set up, I doubt you guys wouldn't know that :D
<Jenz> As the channel is doubly logged, I'll just ask and check the logs later
<FromGitter> <Blacksmoke16> o/
<Jenz> Oh, well hello someone :D
<Jenz> Question is: why are there so many node modules? Is there really any need for that?
<FromGitter> <c910335> @hfjallemark What version of Granite?
<FromGitter> <Blacksmoke16> sadly im not the best to ask about Amber, more of a Granite guy :p
* Jenz :)
<FromGitter> <Blacksmoke16> uh oh, did i break something
<FromGitter> <Blacksmoke16> @hfjallemark i'll check it out when i get home tonight, i have hunch the annotations aren't getting applied....
<FromGitter> <Blacksmoke16> however if you're on version `0.14.1` then it could be something else
<FromGitter> <Blacksmoke16> should add some specs for the json/yaml option stuff....
Jenz has left #amber ["brb"]
<FromGitter> <hfjallemark> I’m on 0.14.2.
<FromGitter> <hfjallemark> And it seems I can’t add json options to relationships either, maybe related
<FromGitter> <Blacksmoke16> try dropping down to `0.14.1`, to confirm my suspicions
<FromGitter> <Blacksmoke16> and there isnt support for json_options on relationships, assuming you mean like `has_one :coach, json_options: xxx`
<FromGitter> <Blacksmoke16> @hfjallemark specs pass fine on granite master, might be something else going on in your case
Jenz has joined #amber
<FromGitter> <Blacksmoke16> model ⏎ ⏎ `````` [https://gitter.im/amberframework/amber?at=5bd32c0064cfc273f92bd8e6]
<FromGitter> <Blacksmoke16> specs
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5bd32c101c100a4f29e9bae1]
<FromGitter> <Blacksmoke16> does it work if you do like `Post.all.to_json`?
<FromGitter> <Blacksmoke16> wonder if its related to the query builder stuff
Jenz has left #amber [#amber]
^raz^ is now known as raz
raz has quit [Changing host]
raz has joined #amber
feepbot has quit [Ping timeout: 245 seconds]
feepbot has joined #amber
<FromGitter> <Blacksmoke16> i made a PR for adding specs for the json/yaml options
<FromGitter> <Blacksmoke16> @hfjallemark As far as i can tell what you have should work
<FromGitter> <Blacksmoke16> `TodoJsonOptions.order(id: :asc).select.to_json` (with same setup as before) => `[{"id":1,"task_name":"last todo"},{"id":2,"task_name":"first todo"},{"id":3,"task_name":"middle todo"}]`
<FromGitter> <hfjallemark> I tried `Post.all` and `Post.find` too
<FromGitter> <Blacksmoke16> let me try adding timestamp fields
<FromGitter> <Blacksmoke16> like you have
<FromGitter> <hfjallemark> But it seems it’s only the created and updated fields
<FromGitter> <hfjallemark> The others work
<FromGitter> <Blacksmoke16> that would have been nice to know :p
<FromGitter> <hfjallemark> @hfjallemark ⏎ It actually works on the other fields ⏎ Just not the created_at/updated_at
<FromGitter> <hfjallemark> :)
<FromGitter> <Blacksmoke16> welp, guess i missed that ha
<FromGitter> <hfjallemark> Hehe -- but re: relationships, is there a reason there is not support for it? Because right now there is no way to ignore the "user_id" field coming out in the json
<FromGitter> <Blacksmoke16> did you try adding the option on the `User` model?
<FromGitter> <hfjallemark> On the class or a specific field?
<FromGitter> <Blacksmoke16> like on the field in the User class
<FromGitter> <hfjallemark> Which field? Because it's the `user_id` field from the `Post` class that is coming, not actually something from the User class
<FromGitter> <hfjallemark> And I haven't even declared a `user_id` field, it must be something created by Granite for the `belongs_to user : User` macro
<FromGitter> <Blacksmoke16> its prob the FK to User table
<FromGitter> <hfjallemark> Yeah, looks like the `belongs_to` macro sets that up: https://github.com/amberframework/granite/blob/master/src/granite/associations.cr#L19
<FromGitter> <hfjallemark> Would be nice to be able to pass `json_options` to `belongs_to` that gets set on that field
<FromGitter> <Blacksmoke16> should be doable
<FromGitter> <Blacksmoke16> first i need to figure this out
<FromGitter> <Blacksmoke16> i can see the annotation getting applied, but doesnt affect the output
<FromGitter> <hfjallemark> Yeah, I'll have a look into it as well
<FromGitter> <hfjallemark> And as soon as I renamed them to `created` and `updated` instead it worked
<FromGitter> <hfjallemark> Could this be it @Blacksmoke16: https://github.com/amberframework/granite/blob/master/src/granite/migrator.cr#L75-L79
<FromGitter> <hfjallemark> Or is that just the SQL migrations?
<FromGitter> <Blacksmoke16> no, its because they are declared on the model even if you dont define them as a field
<FromGitter> <hfjallemark> Ah right
<FromGitter> <hfjallemark> So they get redeclared?
<FromGitter> <hfjallemark> Yeah, was looking at that now
<FromGitter> <Blacksmoke16> yea
<FromGitter> <Blacksmoke16> hm
<FromGitter> <Blacksmoke16> i have a fix, will write some specs and add it to the pr
<FromGitter> <Blacksmoke16> basic im just not setting/updating the times if there isnt a corresponding `field` or `timestamps`
<FromGitter> <hfjallemark> Ah, because they are not used for anything else?
<FromGitter> <Blacksmoke16> yea
<FromGitter> <Blacksmoke16> afaik at least
<FromGitter> <Blacksmoke16> but up till now they were being set/updated even if you didnt declare them
<FromGitter> <Blacksmoke16> which *might* break some people's apps if they were using them without declaring it as an actual field or using the timestamps macro
<FromGitter> <hfjallemark> Right
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5bd3a54a82893a2f3b468197]
<FromGitter> <Blacksmoke16> new spec should handle that
<FromGitter> <Blacksmoke16> also snuck in some query_builder stuff just to have some coverage for that
<FromGitter> <hfjallemark> Nice!
<FromGitter> <Blacksmoke16> good find
<FromGitter> <Blacksmoke16> @c910335 could you review again pls?
<FromGitter> <hfjallemark> Good fix :D
<FromGitter> <Blacksmoke16> also can check out https://github.com/Blacksmoke16/CrSerializer
<FromGitter> <Blacksmoke16> would give you more control over stuff, like consume a value in from_json but not include it when doing to_json
<FromGitter> <Blacksmoke16> also looking for feedback :)
<FromGitter> <Blacksmoke16> am 100% sure it works with granite, will have to read the custom annotation section in granite docs to apply the annotations tho