Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 19 13:48
    remnantkevin starred rom-rb/rom-sql
  • Sep 19 12:20
    wuarmin edited #412
  • Sep 19 12:19
    wuarmin edited #412
  • Sep 19 12:18
    wuarmin opened #412
  • Sep 19 12:18
    wuarmin labeled #412
  • Sep 19 12:18
    wuarmin labeled #412
  • Sep 08 01:34
    masterT starred rom-rb/rom-sql
  • Sep 07 07:06
    nejdetkadir starred rom-rb/rom-sql
  • Aug 25 07:42
    solnic commented #407
  • Aug 25 06:32
    blakkaz starred rom-rb/rom-sql
  • Aug 25 06:32
    blakkaz starred rom-rb/rom-sql
  • Aug 17 13:07
    Rynaro starred rom-rb/rom-sql
  • Aug 16 10:33
    hshatti starred rom-rb/rom-sql
  • Aug 13 08:01

    flash-gordon on main

    Update examples (compare)

  • Aug 09 12:04
    wuarmin commented #407
  • Aug 09 11:40
    flash-gordon commented #407
  • Aug 09 07:02
    wuarmin commented #407
  • Jul 28 23:51
    Clivern starred rom-rb/rom-sql
  • Jul 28 16:44
    elct9620 commented #389
  • Jul 28 16:25
    elct9620 commented #389
Vasily Kolesnikov
@v-kolesnikov
@alex-lairan It isn't dead, I use it in couple of projects in production.
Oskar Szrajer
@gotar
@dawidlenkiewicz
>> Range.new(*[100, 200])
=> 100..200
it's normal ruby code, nothing related to ROM
Lairan
@alex-lairan

@v-kolesnikov how do you setup ?

I have this error on rails c :
https://pastebin.com/CALmeDiP (too big for gitter)

tldr: uninitialized constant Int

Oskar Szrajer
@gotar
@dawidlenkiewicz splat operator | * - for arrays | ** - for hashes
Vasily Kolesnikov
@v-kolesnikov
Looks like incompatible version of dry-types. I recomend you to play with rom-mongo step by step starting from scratch (without Rails).
Oskar Szrajer
@gotar
and you can use just a construction like:
For ranges, Sequel uses a pair of inequality statements:

collection.where(horsepower: 1..5)
# SELECT * FROM ... WHERE ((horsepowert >= 1) AND (horsepower <= 5))
Vasily Kolesnikov
@v-kolesnikov
rails, active-support, bootsnap, rom3... It might be so hard...
Dawid Lenkiewicz
@dawidlenkiewicz
@gotar hmm yes but the problem I'm facing is more Sequel related I think. It works what you wrote but I'm thinking is there a good way of constructing that query when we don't know how many ranges there are (and we need to use OR between them)
Lairan
@alex-lairan
Yes I know :(
Lairan
@alex-lairan
An empty one :
Traceback (most recent call last):
    11: from main.rb:1:in `<main>'
    10: from main.rb:1:in `require'
     9: from /home/necros/.rvm/gems/ruby-2.6.0/gems/rom-3.3.3/lib/rom.rb:14:in `<top (required)>'
     8: from /home/necros/.rvm/gems/ruby-2.6.0/gems/rom-3.3.3/lib/rom.rb:14:in `require'
     7: from /home/necros/.rvm/gems/ruby-2.6.0/gems/rom-3.3.3/lib/rom/relation.rb:5:in `<top (required)>'
     6: from /home/necros/.rvm/gems/ruby-2.6.0/gems/rom-3.3.3/lib/rom/relation.rb:5:in `require'
     5: from /home/necros/.rvm/gems/ruby-2.6.0/gems/rom-3.3.3/lib/rom/relation/class_interface.rb:8:in `<top (required)>'
     4: from /home/necros/.rvm/gems/ruby-2.6.0/gems/rom-3.3.3/lib/rom/relation/class_interface.rb:8:in `require'
     3: from /home/necros/.rvm/gems/ruby-2.6.0/gems/rom-3.3.3/lib/rom/relation/curried.rb:7:in `<top (required)>'
     2: from /home/necros/.rvm/gems/ruby-2.6.0/gems/rom-3.3.3/lib/rom/relation/curried.rb:8:in `<module:ROM>'
     1: from /home/necros/.rvm/gems/ruby-2.6.0/gems/rom-3.3.3/lib/rom/relation/curried.rb:9:in `<class:Relation>'
/home/necros/.rvm/gems/ruby-2.6.0/gems/rom-3.3.3/lib/rom/relation/curried.rb:17:in `<class:Curried>': uninitialized constant #<Module:0x000055ba132ea0b8>::Int (NameError)
source 'https://rubygems.org'

gem 'rom'
gem 'rom-mongo'

gem 'pry'
require "rom"
require "rom-mongo"

rom = ROM.container(:mongo, 'mongodb://localhost:27017/plezi_development')
Piotr Solnica
@solnic
mongo adapter is outdated and not ready for production, I wouldn't recommend using it w/o making it up-do-date with rom 4.x and improving its implementation
Lairan
@alex-lairan
I'm a beginner user of ROM, it's easy to update the gem ? Or should I use Mongoid ?
There is not a lot of files :)
Piotr Solnica
@solnic
this adapter needs a big update, I don't think it's gonna be a simple task, not to discourage you though, just being honest
Lairan
@alex-lairan

Ok, thanks @solnic

I will give up for this one, but use Dry for everything else :D

Vasily Kolesnikov
@v-kolesnikov
@solnic I have tried to upgrade rom-mongo to rom 4.x but pr's have not been reviewed. Could try again if it's needed.
Piotr Solnica
@solnic
@v-kolesnikov nobody from the core team uses mongo so it's hard to keep up with this :(
I'll be working on rom again soon, I'll try to look into mongo adapter and your PR
Oskar Szrajer
@gotar
@dawidlenkiewicz not pretty but should works where{ id.in([[100,200], [500,600]].map{|x| Range.new(*x)}.map(&:to_a).flatten ) }
but for sure there is any option to join with .or
just doesn't remember how
Ethan Turkeltaub
@ethnt
Hi all, I'm having some issues with self-referential relations
Ethan Turkeltaub
@ethnt
The issue I believe is with using a view, I get the error: NoMethodError: undefined methodpreload_assoc' for #<ROM::Relation::Curried:0x00007f85cd8136e8>`
Calling combine(:regions) on the relation produces that error, but only when view is set. I see someone had this issue in 2017 but I'm not sure if it was ever resolved. I'm on ROM 4.2.1
Piotr Solnica
@solnic
@ethnt add override: true
has_many :regions, view: :children, override: true
Ethan Turkeltaub
@ethnt
@solnic D'oh, thanks :) I'm the person from Discourse with the JSON/dry-types serialization issue, I'll work on reproducing it outside of our app. Would that be an issue I report to dry-types?
Piotr Solnica
@solnic
@ethnt pls report in rom repo, it's most likely an issue in rom
Dawid Lenkiewicz
@dawidlenkiewicz
@gotar ah yeah, good idea to convert ranges to one array with values. I think it fits well in my solution, the ranges won't be really big. Thanks
Ethan Turkeltaub
@ethnt
I have a bit of an ideology question: should I be using repositories for querying data if I'm just replicating the same sort of logic in the relations? For example, if I want to get the posts for a user, I'll be calling posts_repository.for_user(user), which just calls posts_relation.for_user(user). Does this make sense or am I going about this the wrong way?
Piotr Solnica
@solnic
@ethnt what does posts_relation.for_user(user) do?
Ethan Turkeltaub
@ethnt
@solnic it's just posts_relation.where(user_id: user.id)
Piotr Solnica
@solnic
then I'd have that in the repo, and I wouldn't have for_user defined in relation
the only situation where it makes sense to define custom relation views (methods) is when query logic is very complex or you need it for composition with other relation views
Oskar Szrajer
@gotar
sometimes for basics calls you will feel like repo and relations are the same but what distinguish them for me:
  • inside relations you define atomes, and you can chain them (like AR scopes)
  • in repo you use those atoms to build more complex queries and you got tuple (records)
that's how i understand and use them, and this helps to understand this for me
# in relations
def active
  ....
end

def by_id(id)
...
end

# in repo
def [](id)
  users.active.by_id(id).one
end
so you have atoms you chain to build final calls and sometimes they will be like 1-1 repo-relation
but probably @solnic will describe and explain it better
Piotr Solnica
@solnic
yes, primary reason for relation views is chaining and composition
and repos are first and foremost the boundary between your app and persistence
Dawid Lenkiewicz
@dawidlenkiewicz

but shouldn't repositories (in theory) always return "materialized" data ?

Like:

# in relation
def for_user(user)
  where(user_id: user.id)
end

# in repo
def for_user(user)
  posts_relation.for_user(user).to_a
end
Oskar Szrajer
@gotar
yeah
you use relations to build (chain) logic (query) and in repo you finish with objects (tuples)
Ethan Turkeltaub
@ethnt
@solnic @gotar @dawidlenkiewicz I think that makes sense. So a summary would be: use repositories to compose the views from relations and to return materialized data?
@solnic @gotar I've wondered, why is the pattern of [](arg) used a lot with ROM/dry over a different method?
Oskar Szrajer
@gotar
a convention, like to use .() in place of .call
[] can be user as a .call to