Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 05:01
    boticello starred rom-rb/rom-sql
  • Nov 25 01:39
  • Nov 24 04:05
    hartca starred rom-rb/rom-sql
  • Nov 22 19:35
    gwilczynski starred rom-rb/rom-sql
  • Nov 22 16:10

    flash-gordon on release-3.6

    Update changelog (compare)

  • Nov 22 16:06

    flash-gordon on v3.6.1

    (compare)

  • Nov 22 16:06

    rom-bot on main

    Update CHANGELOG.md (compare)

  • Nov 22 16:05

    flash-gordon on main

    Update changelog (compare)

  • Nov 22 16:04

    flash-gordon on release-3.6

    Update changelog Update changelog (compare)

  • Nov 22 16:02

    flash-gordon on release-3.6

    Bump version to 3.6.1 (compare)

  • Nov 22 15:53

    flash-gordon on main

    Fix merge conflicts (compare)

  • Nov 22 15:48

    flash-gordon on main

    Revert "Use released dry-transf… (compare)

  • Nov 22 15:44

    flash-gordon on main

    Use released dry-transformer (compare)

  • Nov 22 15:38

    flash-gordon on main

    Fix mapping of PG cidr values t… (compare)

  • Nov 22 15:28

    flash-gordon on fix-cidr-mapping

    (compare)

  • Nov 22 15:28

    flash-gordon on release-3.6

    Fix mapping of PG cidr values t… Merge pull request #414 from ro… (compare)

  • Nov 22 15:28
    flash-gordon closed #414
  • Nov 22 15:22
    flash-gordon synchronize #414
  • Nov 22 15:22

    flash-gordon on fix-cidr-mapping

    Fix mapping of PG cidr values t… (compare)

  • Nov 22 15:19
    flash-gordon synchronize #414
David Dawson
@DangerDawson
I suppose it all depends on the database in question, as from what I can remember the innodb (MySQL) engine stores data locally to its primary keys, which gives you a nice performance boost if just using primary keys for lookups / joins
Nikita Shilnikov
@flash-gordon
good point, at the same time mysql has really poor support for composite pks itself. IIRC there's no way to fetch the PK value after insertion, it also was/is a complication for rom
rom's general pattern let's say
David Dawson
@DangerDawson
So the general advice would be to use composite primary / foreign keys if you are happy to fallback to writing raw SQL and you the extra performance is required, otherwise stick to using singular primary keys
Nikita Shilnikov
@flash-gordon
yes
Lairan
@alex-lairan
Dawid Lenkiewicz
@dawidlenkiewicz

Hey is it possible to have query like for example:

collection.where{(horsepower =~ 100..200) | (horsepower =~ 500..600)}

but doing it dynamically? When the horsepower number of ranges is not known ?

basically by having an array (of n elements) of ranges
Lairan
@alex-lairan
If so, how to connect ROM to a MongoDB database?
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')
Peter 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 :)
Peter 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.
Peter 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
Peter 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?
Peter 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?
Peter 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)
Peter 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