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
wontruefree has joined #amber
wontruefree has quit [Quit: bye]
feepbot has quit [Ping timeout: 252 seconds]
feepbot has joined #amber
<FromGitter> <hfjallemark> Anyone know how to map Postgres numeric types? Getting this error: `PG::ResultSet#read returned a PG::Numeric. A (Float64 | Nil) was expected.` for a field `field origin_x : Float64`
<FromGitter> <drujensen> hhmm, is this related to https://github.com/amberframework/amber/issues/916 ?
<FromGitter> <drujensen> What is PG::Numeric defined as?
<FromGitter> <drujensen> what is the type set in the migration?
<FromGitter> <drujensen> looks like we need to call `to_f64` to get a Float64 back
<FromGitter> <hfjallemark> The type is: `origin_x NUMERIC (20,10) NULL`
<FromGitter> <hfjallemark> Right, some conversion needs to happen.. but it looks like it has to be done in Granite because it throws the error before I get a chance to do any conversion.
<FromGitter> <drujensen> yes, I think we need to look at this closer. The drivers used to only return crystal base types. If they are now returning driver specific types, we will have to have driver specific casting in Granite
<FromGitter> <drujensen> We have a ticket to support custom types. this probably needs to be something we work on sooner rather than later
<FromGitter> <hfjallemark> That would be awesome!
<FromGitter> <drujensen> currently Granite only supports DB::Any
<FromGitter> <Blacksmoke16> @hfjallemark @drujensen ⏎ `````` [https://gitter.im/amberframework/amber?at=5bc745ef271506518d2835d9]
<FromGitter> <eliasjpr> I left a comment on https://github.com/amberframework/granite/issues/152
<FromGitter> <drujensen> @Blacksmoke16 oh, so we also need to import BigRational for precision. hhmm
<FromGitter> <Blacksmoke16> the issue there is the pg adapter shard
<FromGitter> <Blacksmoke16> thats a similar error to what i was getting when trying to do the UUID support
<FromGitter> <Blacksmoke16> in that he's declaring his field as `field origin_x : Float64`
<FromGitter> <Blacksmoke16> but its returning the pg adapter type `PG::Numeric` so he should just have to set his type on his field to `PG::Numeric`
<FromGitter> <drujensen> does that work?
<FromGitter> <Blacksmoke16> it should, thats how its represented in the pg shard
<FromGitter> <eliasjpr> By specifying both, we can do the casting or attempt to do the casting using Crystal type.as(other_type), also it will allow us to create the DB table structure with specific DB types if the user wants more control over that. This is something that I have seen in Hibernate (Java ORM) and many other ORMs
<FromGitter> <hfjallemark> It doesn't
<FromGitter> <hfjallemark> Getting this error: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5bc747e6435c2a518ebfecc8]
<FromGitter> <Blacksmoke16> now *thats* the granite bug
<FromGitter> <drujensen> yeah, we only support DB::Type
<FromGitter> <drujensen> You could redefine it to add that type
<FromGitter> <Blacksmoke16> thats all you should have to do, unless you're using the migrator
<FromGitter> <hfjallemark> Getting this error in runtime when using `DB::Any`: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5bc74853c7bf7c36622751b7]
<FromGitter> <hfjallemark> (`field origin_x : DB::Any`)
<FromGitter> <drujensen> no, you need to redefine the DB::Any to include the PG::Numeric. I’m not sure if you can reopen this or not.
<FromGitter> <drujensen> or if we need to do it in Granite
<FromGitter> <hfjallemark> Ah, will try
<FromGitter> <Blacksmoke16> easiest way for now, is to just go to like ./lib/granite/src/granite/fields.cr and add ` | PG::Numeric` to the Type alias
<FromGitter> <drujensen> you could try adding the type here https://github.com/amberframework/granite/blob/master/src/granite/fields.cr#L5
<FromGitter> <drujensen> lol
<FromGitter> <Blacksmoke16> on line 5
<FromGitter> <Blacksmoke16> yea :p
<FromGitter> <hfjallemark> That works :D
<FromGitter> <drujensen> 👍
<FromGitter> <hfjallemark> But will only work locally (since CI will pull down fresh shards) -- what's the long term solution?
<FromGitter> <drujensen> long term is the ticket #152. I guess we could short term add it to the alias Type?
<FromGitter> <drujensen> Does anyone know, can you redefine a type? override the existing one?
<FromGitter> <hfjallemark> Doesn't seem so
<FromGitter> <hfjallemark> ```code paste, see link``` [https://gitter.im/amberframework/amber?at=5bc74a0764cfc273f9dfc20d]
<FromGitter> <drujensen> If you make a PR, we can get this released as a patch
<FromGitter> <drujensen> does this break mysql though?
<FromGitter> <drujensen> wait, hhmm
<FromGitter> <drujensen> I think we are back to https://github.com/amberframework/granite/issues/152
<FromGitter> <hfjallemark> Heading to bed but let me know if I should open a PR and I'll do that tomorrow! Thanks for all the help :)
<FromGitter> <drujensen> ok. thanks
wontruefree has joined #amber
wontruef_ has joined #amber
wontruefree has quit [Ping timeout: 245 seconds]
wontruef_ has quit [Quit: bye]