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> <yorci> i have an issue with the granite, ⏎ ```Unhandled exception: PG::ResultSet#read returned a Int32. A (Int64 | Nil) was expected. (Exception)```
<FromGitter> <Blacksmoke16> you're column is an `INT` while `Int64?` was set in Granite
<FromGitter> <Blacksmoke16> PK in granite assumes `BIGINT` so thats prob your issue
<FromGitter> <Blacksmoke16> or in case of PG `BIGSERIAL`
<FromGitter> <Blacksmoke16> @yorci
<FromGitter> <yorci> Well if i change the column type integer to bigint in postgresql, it returns that error : ⏎ ⏎ ``` Unhandled exception: PG::ResultSet#read returned a Int64. A (Int32 | Nil) was expected. (Exception) ```
<FromGitter> <Blacksmoke16> can you show your model/schema?
<FromGitter> <yorci> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5c9715085547f7744856c21e]
<FromGitter> <yorci> if i change primary macro type its not any matter
<FromGitter> <Blacksmoke16> and whats the sql schema look like?
<FromGitter> <yorci> oh it could be because i set field of user_id ?
<FromGitter> <Blacksmoke16> possibly
<FromGitter> <yorci> no not working
<FromGitter> <Blacksmoke16> and are sure its related to this model?
<FromGitter> <yorci> yes
<FromGitter> <Blacksmoke16> does it work if you remove the assocations?
<FromGitter> <yorci> exclude unnecessary field
<FromGitter> <yorci> nope
<FromGitter> <yorci> same error
<FromGitter> <Blacksmoke16> basic that error means there is a type mismatch somewhere
<FromGitter> <yorci> yes but where :D
<FromGitter> <Blacksmoke16> its coming back as an `Int64` from the db but you have the type of something as `Int32?`
<FromGitter> <Blacksmoke16> are you not defining any `Int32` fields?
<FromGitter> <yorci> Oh yes
<FromGitter> <yorci> the problem is because of other models
<FromGitter> <yorci> *facepalm*
<FromGitter> <Blacksmoke16> called it
<FromGitter> <Blacksmoke16> ;)
<FromGitter> <yorci> Thank you @Blacksmoke16
<FromGitter> <Blacksmoke16> np
<FromGitter> <Blacksmoke16> i wonder if we could catch that to supply the column/model name
<FromGitter> <yorci> it would be great
<FromGitter> <Blacksmoke16> ill take a look tomorrow
<FromGitter> <yorci> By the way it returns same error if relation macros used :D ⏎ ⏎ no matter primary key type set or not
<FromGitter> <Blacksmoke16> :thinking:
<FromGitter> <Blacksmoke16> iirc by default `belongs_to` uses `Int64` column type
<FromGitter> <Blacksmoke16> would that be it?
<FromGitter> <yorci> yep
<FromGitter> <yorci> can i change it with a macro or method?
<FromGitter> <yorci> i need to hardcode it ?
<FromGitter> <elorest> I'm going to release the latest version of amber tomorrow if I can get the deprecated crecto stuff removed in time.
<FromGitter> <Blacksmoke16> i dont remember tbh
<FromGitter> <yorci> i feel like my db is shitting with me :D
<FromGitter> <yorci> i cant change column types because its already running application, i need to update whole app
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <0x2C6> For Example I want to add new pipe to amber ? What is the suitable structure for it?
<FromGitter> <Blacksmoke16> Hm? Maybe check out the docs?
<FromGitter> <Blacksmoke16> `A pipe is a class which includes HTTP::Handler and implements the #call method.`
<FromGitter> <0x2C6> checked but don't know how to create new crystal app file to communicate with amber pipes
<FromGitter> <0x2C6> it should be something like 3rd library installed with shards
<FromGitter> <Blacksmoke16> im pretty sure its just like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5c97972681b15c5e4b7bd50a]
<FromGitter> <Blacksmoke16> then like `pipe MyPipe.new`
<FromGitter> <0x2C6> okay did something like that
<FromGitter> <0x2C6> moved app to ./lib directory
<FromGitter> <Blacksmoke16> wait what?
<FromGitter> <0x2C6> and required it on the router.cr
<FromGitter> <Blacksmoke16> `lib` directory is for shards, your app file should be under `src`?
<FromGitter> <0x2C6> require "../lib/test_pipe/src/test_pipe.cr"
<FromGitter> <0x2C6> yes I know :D I moved it there just for test :D
<FromGitter> <0x2C6> just wondering can I use it without requiring in router.cr?
<FromGitter> <0x2C6> would it work if I upload it to github and install as a shard?
<FromGitter> <Blacksmoke16> you shouldnt have to do that
<FromGitter> <Blacksmoke16> should just go to your like `/config/routes.cr` and require it there, then add `pipe MyPipe.new`?
<FromGitter> <0x2C6> yes I want to use it in that way but unless I require, it raise Undefined Constant error
<FromGitter> <0x2C6> maybe it will work when installing it as shard
<FromGitter> <Blacksmoke16> well yea you need to tell it that you need
<FromGitter> <0x2C6> I'll try
<FromGitter> <Blacksmoke16> otherwise you just have a random `my_pipe.cr` file hanging around that isnt included anywhere
<FromGitter> <Blacksmoke16> prob could also require it at a higher level like `config/application.cr`
<FromGitter> <0x2C6> Okay I found out that if you want to create new new pipe you should you that app/src/amber/pipe/app.cr structure. Otherwise it raise error
<FromGitter> <Blacksmoke16> makes sense, would be similar to your `controllers` directory etc
<FromGitter> <0x2C6> Now I will try to upload it to github and pull again as a shard and try to use it withoud requiring in routes.cr
<FromGitter> <Blacksmoke16> pull what as a shard? a whole amber app with 1 pipe in it?
<FromGitter> <0x2C6> just added gitrepo to shards file
<FromGitter> <Blacksmoke16> ok
<FromGitter> <0x2C6> you think I'm stupid. Aren't you? :D
<FromGitter> <Blacksmoke16> it sure seems your doing a lot of work for something that would be solved by doing like `require "../src/pipes/*"`in your app's `config/application.cr`
<FromGitter> <Blacksmoke16> granted i never actually used amber so maybe you know something i dont :P
<FromGitter> <0x2C6> I want to keep them separated thats why I don't want to put them to src
<FromGitter> <Blacksmoke16> why tho? if you're amber app *needs* that pipe?
<FromGitter> <0x2C6> as a gem :D
<FromGitter> <Blacksmoke16> alright
<FromGitter> <0x2C6> Ok I install it as a shard but amber doesn't auto require it :(
<FromGitter> <0x2C6> any idea?
<FromGitter> <Blacksmoke16> ☝️ March 24, 2019 11:07 AM (https://gitter.im/amberframework/amber?at=5c979d17dfc69a1454e9b834)
<FromGitter> <0x2C6> except that :D
<FromGitter> <Blacksmoke16> unless someone else has some magic idea im not sure what else you can do, amber doesn know about the file, you need to require the file :shrug:
<FromGitter> <0x2C6> how amber autoloads all shards?
<FromGitter> <0x2C6> but then how it works with granite or etc?
<FromGitter> <0x2C6> Hmmm I thing you're right
<FromGitter> <0x2C6> all have configuration files with require line :(
<FromGitter> <0x2C6> kinda frustrating
<FromGitter> <Blacksmoke16> i dont see how its a big deal?
<FromGitter> <0x2C6> anyway. Thanks you for your help :D. After all I learned something new today
<FromGitter> <Blacksmoke16> np
<FromGitter> <0x2C6> one last thing
<FromGitter> <0x2C6> ;)
<FromGitter> <0x2C6> about deployment
<FromGitter> <0x2C6> forget about deploy command :D
<FromGitter> <0x2C6> at the one of the old messages a man suggested me mina.js for deploy
<FromGitter> <Blacksmoke16> im not the best to ask about that unfortunately
<FromGitter> <0x2C6> but I just clone and compile it on the server and run it
<FromGitter> <0x2C6> no problem maybe someone else will read it
<FromGitter> <0x2C6> I run it at background and write the process pid to another folder. I thing it isn't a good practice
<FromGitter> <0x2C6> Open for suggestions :D
<FromGitter> <rmarronnier> Hey all, I'm going crazy, maybe you can help me : '''settings.database_url = ENV["DATABASE_URL"] if ENV["DATABASE_URL"]?''' is uncommented in my '''application.cr'''
<FromGitter> <rmarronnier> And I've done '''export DATABASE_URL="test"''' in my terminal
<FromGitter> <rmarronnier> printenv shows it
<FromGitter> <rmarronnier> and yet when I start my application with amber watch, its picks the url from my development.yml file
<FromGitter> <rmarronnier> I thought : # Any uncommented setting here will override the YAML with the value set here.
<FromGitter> <rmarronnier> Do you have any pointers ?
<FromGitter> <rmarronnier> I need the database url to be set by the env variable (I'm hosting my app on Heroku, and I don't want anymore to hardcode the URL in my .yml, because it keeps changing)
<FromGitter> <Blacksmoke16> might have to change like amber env var to use prod config file? @rmarronnier ?
<FromGitter> <elorest> @rmarronnier Give me a second.
<FromGitter> <elorest> settings are definitely being loaded in correctly and overwritten by ENV vars. @Blacksmoke16 Has a change in granite been made that ignores settings and looks at the environment files directly?
<FromGitter> <Blacksmoke16> Granite doesn't set anything on it's own
<FromGitter> <Blacksmoke16> Only uses what you define when adding your adapter
<FromGitter> <elorest> database.cr was changed quite a bit a couple months ago and moved from `./config/initializers` to `./config`. I'm doing a couple tests right now.
<FromGitter> <elorest> @Blacksmoke16 @rmarronnier `./config/database.cr` is being loaded before `Amber::Server.configure` is run.
<FromGitter> <Blacksmoke16> is that bad?
<FromGitter> <elorest> Yes. Because the database adapter is initialized with the wrong settings.
<FromGitter> <elorest> It's possible it's been like this for a while. I'm looking back through history. Originally settings used a macro to load which allowed them to read in env vars pre runtime. This had other disadvantages though... mostly harder to read code, so it was refactored. I feel like this wasn't an issue even after the refactor though.
<FromGitter> <elorest> Looking through history.
<FromGitter> <Blacksmoke16> is an amber issue then?
<FromGitter> <elorest> Yes.
<FromGitter> <Blacksmoke16> 👍 i figured
<FromGitter> <elorest> @rmarronnier I'll fix and release this ASAP. But for now just move these lines from the beginning of `application.cr` to the end. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5c9818f50d719050575d44af]
<FromGitter> <elorest> @Blacksmoke16 Looks like the bug was introduced when support for Crecto was added. Something which probably needs to be removed since it's not longer maintained.
<FromGitter> <Blacksmoke16> Crecto itself or the support for amber?
<FromGitter> <rmarronnier> oh thanks god ! Isaac Sloan :-D
<FromGitter> <rmarronnier> It's weird noone came across this problem before...
<FromGitter> <rmarronnier> anyway thanks for your help