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
<FromGitter> <AhsenBaig_gitlab> Hello, I just did a fresh install of Crystal and Amber. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5d955a01eac5612d22a52b94]
<FromGitter> <drujensen> Change amber to use master branch
<FromGitter> <drujensen> We still need to release fixes for crystal 0.31.0
<FromGitter> <AhsenBaig_gitlab> I believe it is the master branch. Pet-tracker shard.yml ⏎ ⏎ ``` amber: ⏎ github: amberframework/amber ⏎ version: 0.30.1 ⏎ #branch: master``` [https://gitter.im/amberframework/amber?at=5d95619d7aa5602ffc5c524a]
<FromGitter> <AhsenBaig_gitlab> or you mean the main install?
<FromGitter> <drujensen> Comment out version
<FromGitter> <AhsenBaig_gitlab> Sorry still new to amber and crystal. So comment version and uncomment branch?
<FromGitter> <drujensen> Uncomment branch
<FromGitter> <AhsenBaig_gitlab> Got it.
<FromGitter> <AhsenBaig_gitlab> No still same issue.
<FromGitter> <drujensen> Hhmm. Shards update?
<FromGitter> <drujensen> Can you paste the results?
<FromGitter> <AhsenBaig_gitlab> Sorry one moment.
<FromGitter> <AhsenBaig_gitlab> Sorry I did that in the wrong directory works now :)
<FromGitter> <AhsenBaig_gitlab> oh great now markd.git complains.
<FromGitter> <AhsenBaig_gitlab> ```Fetching https://github.com/icyleaf/markd.git ⏎ Error resolving pg (~> 0.19.0, ~> 0.18.0)``` [https://gitter.im/amberframework/amber?at=5d9562a5940b4c2fc0662370]
<FromGitter> <drujensen> Weird. Markd shouldn’t have a dependency on of
<FromGitter> <AhsenBaig_gitlab> Yeah... I can rm -rf it and try again perhaps my mods messed something up?
<FromGitter> <AhsenBaig_gitlab> No same issue on pet-tracker
<FromGitter> <AhsenBaig_gitlab> That has a reference to markd.git.
<FromGitter> <drujensen> What version do you have listed for pg?
<FromGitter> <drujensen> Should be 19
<FromGitter> <AhsenBaig_gitlab> ``` pg: ⏎ github: will/crystal-pg ⏎ version: ~> 0.18.0``` [https://gitter.im/amberframework/amber?at=5d95674fb385bf2cc663dc01]
<FromGitter> <AhsenBaig_gitlab> Updated it to 19. Doing shards update.
<FromGitter> <AhsenBaig_gitlab> Ok that finally worked thank you. I would suggest that the main pet-tracker app be updated for new users.
<FromGitter> <drujensen> Will do. We will release soon.
<FromGitter> <AhsenBaig_gitlab> Awesome! Thank you once again.
<FromGitter> <elorest> @drujensen 0.30.1 worked a few days ago when I tested it, after the crystal-db, micrate issue. Has something else changed?
<FromGitter> <elorest> @AhsenBaig_gitlab I'm trying to track down this issue. Nothing in amber 0.30.1 should be requiring `crystal-db` 0.7. I wonder what changed.
<FromGitter> <drujensen> @elorest ok, I deleted 0.17.3 tagged release and released 0.18.0
<FromGitter> <drujensen> hopefully that will fix current users
<FromGitter> <drujensen> we will need to bump the version for amber master to work
<FromGitter> <drujensen> I will create a pr
<FromGitter> <Blacksmoke16> @drujensen @elorest @eliasjpr @robacarp opinions on having users define their own initialize methods for Granite modles?
<FromGitter> <Blacksmoke16> it would ofc be a massive breaking change, but it would allow for things to work in a more crystalesque way.
<FromGitter> <Blacksmoke16> i.e. we could get rid of `#set_attributes`, compile time errors if you try to do like `Book.new(title: 19)` where `title` is defined as a `String`
<FromGitter> <Blacksmoke16> main downside would obs be more responsibility on the user, require them to define the initializer for all their models
<FromGitter> <Blacksmoke16> might look into if there is a better way to automatically define the initializers, to still allow getting rid of `#set_attributes`, but we'll see
<FromGitter> <drujensen> @Blacksmoke16 I would be ok with creating a different initializer that takes params hash instead of `new`
<FromGitter> <drujensen> that way in Amber, we can replace `Post.new params` with something like `Post.build params`
<FromGitter> <drujensen> or in Amber, we handle the conversion of param values to types and remove this completely from Granite
<FromGitter> <Blacksmoke16> im more in favor of the latter
<FromGitter> <Blacksmoke16> thats essentially the only custom thing that is in `#set_attributes`
<FromGitter> <Blacksmoke16> if we are able to ditch that, then it should be easier to define initializers for fields that take advantage of the compile time errors
<FromGitter> <drujensen> well, we will always have runtime errors since http doesn’t support types. ;-)
<FromGitter> <drujensen> but if someone was using Granite outside of Amber, I can see the desire to move this out
<FromGitter> <drujensen> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5d965c460e67130aae0c1359]
<FromGitter> <drujensen> This is the offending code
<FromGitter> <drujensen> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5d965c6f3220922ffb22f459]
<FromGitter> <drujensen> `post_params` might be a good place to do the conversion. The problem is keeping this stuff dry
<FromGitter> <drujensen> we already define the types in the model
<FromGitter> <drujensen> we would have to define the types twice
<FromGitter> <drujensen> in Amber and Granite
<FromGitter> <drujensen> somewhere we need to convert the `params` from an http request to the appropriate type
<FromGitter> <Blacksmoke16> what are `params`?
<FromGitter> <Blacksmoke16> like form data?
<FromGitter> <drujensen> yes
<FromGitter> <drujensen> or json
<FromGitter> <drujensen> if its an api
<FromGitter> <drujensen> bottom line is there is a runtime conversion
<FromGitter> <Blacksmoke16> for sure, if its a JSON body it should just utilize `from_json`
<FromGitter> <drujensen> what if we add `from_params`?
<FromGitter> <drujensen> its the same type of logic
<FromGitter> <Blacksmoke16> that takes a https://crystal-lang.org/api/master/HTTP/Params.html
<FromGitter> <Blacksmoke16> yes i would be ok with that
<FromGitter> <drujensen> ``````
<FromGitter> <drujensen> I am good with this change as well
<FromGitter> <drujensen> then remove the initializer logic so `Post.new` will be the default
<FromGitter> <Blacksmoke16> this kinda relates to https://github.com/amberframework/amber/issues/698
<FromGitter> <drujensen> @elorest @eliasjpr any concerns with this change?
<FromGitter> <Blacksmoke16> however i would think that the `from_params` would live inside of Amber
<FromGitter> <Blacksmoke16> as an ext to Granite for HTTP stuff
<FromGitter> <drujensen> why?
<FromGitter> <drujensen> we added from_json
<FromGitter> <drujensen> why not `from_params`?
<FromGitter> <Blacksmoke16> from_json just kinda works with the stdlib, id also be open to removing the serializable stuff by default and if the user wants it they can just include it
<FromGitter> <drujensen> oh, yes. i’m ok with modularizing it
<FromGitter> <robacarp> I'm in favor as well
<FromGitter> <drujensen> not sure it requires a separate shard though
<FromGitter> <Blacksmoke16> separate shard?
<FromGitter> <Blacksmoke16> im not too familiar with how it works now but i was just picturing amber reopneing Granite::Base and adding the method
<FromGitter> <drujensen> hhmm
<FromGitter> <Blacksmoke16> or, better idea
<FromGitter> <Blacksmoke16> this kinda goes along with some thoughts i had around athena, https://github.com/Blacksmoke16/athena/issues/34
<FromGitter> <Blacksmoke16> been thinking about how to handle these extensions
<FromGitter> <drujensen> yes, have the user include the functionality they want
<FromGitter> <Blacksmoke16> i.e. do they live with the shard they are part of, or with the project that uses that functionality
<FromGitter> <drujensen> `include Granite::Serializers`
<FromGitter> <Blacksmoke16> the former would prob be easier to maintain, as it could be tested and stuff
<FromGitter> <drujensen> well, I don’t know why this wouldn’t be in granite
<FromGitter> <drujensen> but maybe i’m missing something
<FromGitter> <Blacksmoke16> thinking about it more i tend to agree
<FromGitter> <Blacksmoke16> but maybe as an ext, like `require "granite/ext/http"`?
<FromGitter> <Blacksmoke16> eh idk
<FromGitter> <drujensen> not following
<FromGitter> <drujensen> ooohhh
<FromGitter> <drujensen> no,no
<FromGitter> <drujensen> so we will only accept a hash in the `from_params`
<FromGitter> <drujensen> not the Http::Params
<FromGitter> <drujensen> I see why you are concerned
<FromGitter> <drujensen> maybe `from_hash` is better
<FromGitter> <drujensen> Amber can do `params.to_h`
<FromGitter> <drujensen> does that help?
<FromGitter> <Blacksmoke16> what is the type of `params` tho?
<FromGitter> <drujensen> a hash
<FromGitter> <drujensen> wait
<FromGitter> <drujensen> sorry, what do you mean?
<FromGitter> <Blacksmoke16> if its already a hash, do you not have to call `.to_h` on it? or was that just a typo?
<FromGitter> <drujensen> checking...
<FromGitter> <drujensen> I think params is an Http::Params object
<FromGitter> <Blacksmoke16> i think that would be preferable no?
<FromGitter> <Blacksmoke16> but im not sure what the crystal way of handling stuff like this should be
<FromGitter> <drujensen> Ok, granite should not be dependent on Http
<FromGitter> <drujensen> or anything related to web
<FromGitter> <drujensen> so the contract between Amber and Granite should be passing by a generic data structure
<FromGitter> <drujensen> like Array or Hash
<FromGitter> <drujensen> or Json
<FromGitter> <drujensen> do you agree?
<FromGitter> <Blacksmoke16> i need to think about how all this would tie together
<FromGitter> <Blacksmoke16> way im seeing this now is granite should be basically just a fancy class that interacts with a database
<FromGitter> <Blacksmoke16> extra features, like serialization, should be able to be included, i.e. `Include JSON::Serializable`, or `include MySerializer`
<FromGitter> <drujensen> yes, single responsibility
<FromGitter> <drujensen> could be separate shards but yes
<FromGitter> <drujensen> Granite extensions?
<FromGitter> <Blacksmoke16> the extension part im not sure how to go about yet
<FromGitter> <drujensen> probably best in the granite shard
<FromGitter> <drujensen> ok, forget that for now
<FromGitter> <Blacksmoke16> to wrap this up id be ok with including an overload in granite for HTTP::Params
<FromGitter> <Blacksmoke16> for now
<FromGitter> <drujensen> to keep this generic, what if we allow for any `Enumerable(K, V)`?
<FromGitter> <eliasjpr> I like it @drujensen
<FromGitter> <Blacksmoke16> possibly
<FromGitter> <drujensen> hi @eliasjpr
<FromGitter> <elorest> Hey
<FromGitter> <drujensen> https://crystal-lang.org/api/0.31.1/HTTP/Params.html supports Enumerable(K, V)
<FromGitter> <eliasjpr> Will from Params take care of nesting?
<FromGitter> <drujensen> hhhmm, very good question
<FromGitter> <eliasjpr> That must have been a new addition
<FromGitter> <eliasjpr> Nesting, arrays and the different scopes are my main concern
<FromGitter> <drujensen> in theory, the value could be another hash
<FromGitter> <drujensen> brain is exploding...
<FromGitter> <Blacksmoke16> ikr? :p
<FromGitter> <eliasjpr> Then you have path params, form params query params
<FromGitter> <drujensen> so a 1 to many relationship would pre-populate from nested params?
<FromGitter> <drujensen> this happens in Rails but there is special naming convention
<FromGitter> <eliasjpr> I always found that implementing nested params is way too complex
<FromGitter> <eliasjpr> We could use http params serializer shard
<FromGitter> <Blacksmoke16> the more we can rely on the standard behavior of crystal the better we are
<FromGitter> <eliasjpr> I know
<FromGitter> <drujensen> agree
<FromGitter> <Blacksmoke16> i.e. there should just be an initializer for each native type, `HTTP::Params` being one
<FromGitter> <drujensen> hhhmmm
<FromGitter> <drujensen> not sure
<FromGitter> <eliasjpr> I think we should propose an rfc to match params to classes
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/assert 😉
<FromGitter> <Blacksmoke16> then your validations are tied to your object
<FromGitter> <Blacksmoke16> which (most of the time?) matches your orm models
<FromGitter> <drujensen> brb
<FromGitter> <Blacksmoke16> the main thing im struggling with is how to best support these "extensions", them having their own shard seems overkill, but having them in `Amber` repo makes it hard to keep up to date to Granite changes
<FromGitter> <Blacksmoke16> having them in `Granite` repo seems like the best idea, but just have them requireable, `require "granite/ext/http"`, which i imagine `Amber` could require automatically?
<FromGitter> <Blacksmoke16> anyway, we're prob getting ahead of ourselves, ill play around with removing `set_attributes` and see how it goes and go from there
<FromGitter> <Blacksmoke16> afk driving home
<FromGitter> <elorest> There still seems to be something in granite which is requiring `crystal-db` 0.7.0. Trying to track that down but I'm in a meeting.
<FromGitter> <drujensen> ok
<FromGitter> <elorest> Fixed it. My shard cache had the old tag.
<FromGitter> <samholst> @drujensen @elorest I'm going to try and get some more of the pending tests to pass on dru's branch
<FromGitter> <drujensen> @samholst Thanks!
<FromGitter> <elorest> Thanks.