These are chat archives for dry-rb/chat

26th
Apr 2017
Piotr Solnica
@solnic
Apr 26 2017 08:14
@flash-gordon hey man, I want to release dry-types 0.10.0 with these two changes you’ve made
you ok with that?
I tested it against rom/rom-sql, looks good
Nikita Shilnikov
@flash-gordon
Apr 26 2017 08:19
@solnic yes, feel free
Piotr Solnica
@solnic
Apr 26 2017 08:19
I bumped to 0.10.0 btw
since meta change is (a bit) significant
Piotr Solnica
@solnic
Apr 26 2017 09:34
@flash-gordon bad news, specs in my app started to fail when I upgraded to dry-t 0.10 :(
Oskar Szrajer
@gotar
Apr 26 2017 09:37
I have a question, there is logger automatically created for dry-web, can I overwrite it somehow? Normal way do not works: There is already an item registered with the key "logger" (Dry::Container::Error). I want to change it to force logger to log to STDOUT, not to file
Piotr Solnica
@solnic
Apr 26 2017 09:46
@gotar it’s a configuration setting
Nikita Shilnikov
@flash-gordon
Apr 26 2017 09:46
@solnic what's wrong?
Piotr Solnica
@solnic
Apr 26 2017 09:46
that’s the funny part, I have no clue
worse part - specs pass when run individually
Nikita Shilnikov
@flash-gordon
Apr 26 2017 09:47
oh wow, love that
Piotr Solnica
@solnic
Apr 26 2017 09:47
which makes me think there’s some global state
that keeps changing between spec runs
and some specs depend on it and they fail
Piotr Solnica
@solnic
Apr 26 2017 09:53
all failures are related to structs being initialized with a missing attribute
Piotr Solnica
@solnic
Apr 26 2017 10:05
@flash-gordon got it
we missed the fact we no longer equalize on :meta too
for some reason it broke some other things
as ie Types::String == Types::String.meta(i_am: “different”) returns true
which is a bug
you wrote specs that specifically check if this works like that, so I wonder why?
we set meta to empty hash by default, so Types::String == Types::String.meta({}) # true
Nikita Shilnikov
@flash-gordon
Apr 26 2017 10:27
@solnic because we need to support things like hash[type]
in some way
Piotr Solnica
@solnic
Apr 26 2017 10:27
where?
types with different meta are not the same, so I don’t think it’s a good idea to treat them as such
oh, yes, the latter is now solved since we have an empty hash by default, but anyway
Nikita Shilnikov
@flash-gordon
Apr 26 2017 10:33
tbh the reason I did this is that we don't have type ast transformations yet, otherwise I'd trim a tree with excluding metas
and I'm not sure whether it's a good idea to use meta in comparisons. But I'm OK with that. So we need another way to drop meta then
Nikita Shilnikov
@flash-gordon
Apr 26 2017 10:41
this can be done with .with(meta: {})
Piotr Solnica
@solnic
Apr 26 2017 10:45
that’s a tough one
I wonder what’s less surprising to be honest
Nikita Shilnikov
@flash-gordon
Apr 26 2017 10:46
exactly
Piotr Solnica
@solnic
Apr 26 2017 10:46
ie ROM::SQL::Types::Int.meta(primary_key: true) == ROM::SQL::Types::Int # true does not look reasonable
those two things mean two different things after all
this can easily bite us in many places
Nikita Shilnikov
@flash-gordon
Apr 26 2017 10:47
but I'd say relying on this is a bad idea
Piotr Solnica
@solnic
Apr 26 2017 10:47
we use various enumerable methods to find attributes so…dunno
why you think that?
Nikita Shilnikov
@flash-gordon
Apr 26 2017 10:48
why would you compare two types like this? Why would compare them at all?
Piotr Solnica
@solnic
Apr 26 2017 10:49
we do that man and it is useful
ie projecting attributes and then using uniq
or checking if an attribute exist in a schema
all these things rely on equality
and in general it’s about semantics too, like in this PK example I showed, two types, one with special meaning, they are not the same
besides, for hash-based mappings we can use a different method for getting some identifier for a type object
Nikita Shilnikov
@flash-gordon
Apr 26 2017 10:52
@solnic don't get me wrong, I don't say they are the same, I'm just wondering how this is used
Piotr Solnica
@solnic
Apr 26 2017 10:53
can’t remember exact places
but it’s clearly used given that our specs started to fail
would be good to track it down of course, but I don’t have time :(
Nikita Shilnikov
@flash-gordon
Apr 26 2017 10:55
two different approaches are using a type as something that acts as a type and using a type like an object, I think that's the difference
@solnic so we need a method to strip out meta, wdyt?
Piotr Solnica
@solnic
Apr 26 2017 10:56
Type#pristine? O_o
but if AST transformations could be used to trim types for special purposes, then maybe we should focus on that
Nikita Shilnikov
@flash-gordon
Apr 26 2017 11:01
whatever name you like :) Even with AST this would be useful. The only difference is that AST trimming will trim the whole tree, that is erase meta from underlying types as well
@solnic OK, you now can merge this one https://github.com/dry-rb/dry-types/pull/188/files and I will add Type#pristine tomorrow
Piotr Solnica
@solnic
Apr 26 2017 11:02
right
we’ll see what makes sense
Nikita Shilnikov
@flash-gordon
Apr 26 2017 11:03
and in the next version we'll add AST transformations, this will make Type#pristine better. That's the plan. I think
I also pushed a small fix for Any
Piotr Solnica
@solnic
Apr 26 2017 11:06
I saw that, cool
can I release 0.10.1 later today?
Nikita Shilnikov
@flash-gordon
Apr 26 2017 11:17
yes
Egor Lynko
@flexoid
Apr 26 2017 13:50
Hi guys. I have an issue, this simple line of code leads to huge performance impact in my use case
https://github.com/dry-rb/dry-types/blob/master/lib/dry/types/definition.rb#L67
the thing is, I use dry-validation in pair with reform, and my input is a Reform::Form object, which has quite a lot fields by itself, and also parent form in :parent property (recursively to the root form)
so, input.inspectbecomes quite heavy call, and if the property is validated with maybe, it always firstly tried to convert to NilClass, which runs this routine many many times
Egor Lynko
@flexoid
Apr 26 2017 13:55
How do you think, what can be done in this situation? Does this entire approach is efficient enough?
to be more specific, removing that inspect call reduces query execution time from 4s to 0.2s