Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 16 12:09
    Lokideos starred rom-rb/rom-sql
  • Oct 15 22:24
    jodosha starred rom-rb/rom-sql
  • Oct 14 18:36
    katafrakt commented #403
  • Oct 14 18:35
    katafrakt synchronize #403
  • Oct 14 14:15
    katafrakt commented #403
  • Oct 14 11:47
    flash-gordon commented #403
  • Oct 13 22:45
    katafrakt edited #403
  • Oct 13 22:44
    katafrakt edited #403
  • Oct 13 22:43
    katafrakt opened #403
  • Oct 13 22:30
  • Oct 12 06:38
    solnic commented #366
  • Oct 11 23:44
    katafrakt commented #366
  • Oct 08 13:41
    wuarmin commented #163
  • Oct 08 07:33
    wuarmin commented #163
  • Oct 08 07:00
    wuarmin commented #163
  • Sep 27 20:39
    dependabot[bot] labeled #336
  • Sep 27 20:39
    dependabot[bot] labeled #336
  • Sep 27 20:39
    dependabot[bot] opened #336
  • Sep 27 20:39

    dependabot[bot] on bundler

    Bump nokogiri from 1.11.4 to 1.… (compare)

  • Sep 17 12:40
    hartca starred rom-rb/rom-mongo
Vasily Kolesnikov
@v-kolesnikov
I do it manually in my projects, it is not so complex.
Grzegorz Wcisło
@grzegorz-wcislo
Ok, thanks
winslo
@winslo12_twitter
Hi, I'm just getting started playing around with ROM, and after reading the relations docs I am unsure how we are expected to access the underlying relation in the ROM environment, the way I am doing it now is something like ROM.env.relations[:users] -- this seems odd to me, have I missed something completely?
Tim Riley
@timriley
@winslo12_twitter You typically want to access them through repositories: https://rom-rb.org/4.0/learn/repositories/quick-start/
Piotr Solnica
@solnic
@/all hey y'all, just like in case of dry-rb, we are switching from Gitter to Zulip so please sign up here: https://rom-rb.zulipchat.com/register/ and let's continue chatting on Zulip :smile:
Andreas Wagner
@whysthatso

hey all. i got a question regarding rom in hanami, which the hanami chat couldn't help me with so far:

i have some trouble constructing a nested dataset for an index view.
i have these associated objects: subscription has plan, plan has fee. besides, subscription has client. in my index i need data from all four objects.
i'm trying to to figure out how to create a query which will give me the nested datastructure that i will need. based on the examples in the documentation i can already get either subscription with client or subscription with plan.

 def all_with_clients_and_plans
    aggregate(:clients, :plans)
  end

this is how far i got, as clients and plans are directly associated with subscription. handling the resulting ROM::Struct as an array by calling each on it is also fairly self explanatory. however, i do not understand how i can add the missing fee data that is associated to plan, or the missing client, all in the same query, or how i can have multiple queries and then construct the right array from that.

i think what i need is some sort of recursive aggregate. is that correct or am i doing something really wrong? i feel like i am coupling stuff too tighlyt, but i certainly need it in the index view. the question really is where i should put that query logic, i think.

there are samples of wrap and combine mentioned in the rom docu, but those don't seem to really do anything on this particular set. having read a bit more about the rom docs, i think i might actually be able to achieve this with custom views, as described here https://rom-rb.org/current/learn/sql/associations/

however, when adding this to my association block, there's really not any effect. checking in the source, it seems that everything in the associations block is just handed down to ROM so i must be doing something wrong here, or misunderstanding how this works.
this is how i've tried custom views

class SubscriptionRepository < Hanami::Repository
  associations do
    belongs_to :client
    has_many :plans, view: :with_fees
  end

  def all_with_clients_and_plans
    aggregate(:clients, :plans)
  end
end
class PlanRepository < Hanami::Repository
  associations do
    has_one :agreement

    belongs_to :fee
    belongs_to :subscription
  end

  def with_fees
    aggregate(:fees)
  end
end

however, all i'm getting on SubscriptionRepository.new.all_with_clients_and_plans
is
NoMethodError: undefined methodwith_fees' for #<#<Class:0x0000562a00cdaca0>:0x0000562a00bcadb0>`

Viet (Drake) Tran
@tiev
@whysthatso you should ask in zulip. this gitter is being abandoned. Details in the message before your message
Andreas Wagner
@whysthatso
i'll cp it there but currently in zulip there are merely 12 people...
Ravic
@aznc0der
Hello guys, any ideas on how to test rom-repository with RSpec?
Andreas Wagner
@whysthatso
@aznc0der WE MOVED TO ZULIP => https://rom-rb.zulipchat.com <=
it's better :)
Marcin Lewandowski
@martio

Hi,

how to use rom-rb and dry-system-rails (dry-container and dry-auto_inject)?

config/initializers/system.rb

Dry::System::Rails.container do
  config.auto_register << 'app/repositories'
  config.auto_register << 'app/services'
end

app/services/create_user.rb

class CreateUser
  include Blog::Import['user_repository']

  def call(user_attrs)
    users_repository.create(user_attrs)
  end
end

app/repositories/user_repository.rb

class UserRepository < ROM::Repository[:users]
end
Marcin Lewandowski
@martio
$ rails console
Loading development environment (Rails 6.0.2.1)
2.6.5 :001 > cu = CreateUser.new
Traceback (most recent call last):
1: from (irb):1
Dry::Container::Error (Nothing registered with the key "user_repository")
2.6.5 :002 >
Ed Balbino
@ebalbino
hello
I'm having a problem setting up my relations
class Conversations < ROM::Relation[:sql]
  schema do
    attribute :id, Types::Integer
    attribute :sender_id, Types::Integer
    attribute :receiver_id, Types::Integer
    attribute :created_at, Types::DateTime
    attribute :updated_at, Types::DateTime

    associations do
      has_many :messages
      belongs_to :profiles, as: :sender, foreign_key: :sender_id
      belongs_to :profiles, as: :receiver, foreign_key: :receiver_id
    end
  end
end
class Profiles < ROM::Relation[:sql]
  schema do
    attribute :id, Types::Integer
    attribute :name, Types::String
    attribute :type, Types::String

    associations do
      has_many :conversations
      has_many :platform_details
    end
  end
end
When I run a combine to get a conversation with its two profiles, I get a KeyError (nil attribute doesn't exist in profiles schema)
I'm assuming that I need to set up my associations in the Profiles relation differently but I'm not sure how
Lairan
@alex-lairan
@ebalbino WE MOVED TO ZULIP => https://rom-rb.zulipchat.com <=
crokobit
@crokobit
Any similar projects like ROM in Python?
Kazuya Hatanaka
@ippachi
Root
Nikolay Markov
@mainameiz

Hello. Could you please help me with adding a custom command to rom-sql?

module ROM
  module SQL
    module Commands
      class BulkInsert < ::ROM::Commands::Create
        # just for simplicity it is now a copy paste from original "create" command from here https://github.com/rom-rb/rom-sql/blob/df787f6776aa743d706eda3cd1e2ea401b20e6c3/lib/rom/sql/commands/create.rb#L5

I got the following error:

  1) Aggregate monthly user document readings with books with regular subscription aggregates readings with related data
     Failure/Error: user_book_readings.bulk_insert(*reading_attributes)

     ROM::CommandNotFoundError:
       There is no :bulk_insert command for :monthly_user_book_readings relation

(NOTE: I'm using rom-sql 2.5.0 and cannot upgrade to newer version for now)

I suppose that there is a simple solution, like I just need to call some method to register new command, but I can figure it out.

I already tried this code which works partially.
But there is another problem - "timestamps" plugin does not work (it does not add timestamps).
# frozen_string_literal: true

module Persistence
  module Commands
    module MonthlyUserBookReadings
      class BulkInsert < ::ROM::SQL::Commands::BulkInsert
        relation :monthly_user_book_readings
      end
    end
  end
end

module Jeeves
  module Persistence
    module Repositories
      class UserBookReadings < Jeeves::Repository[:monthly_user_book_readings]
        commands :bulk_insert,
                 use: :timestamps,
                 plugins_options: { timestamps: { timestamps: %i[created_at] } }
Vivian Maes
@vivian-maes
Hello, I try to use ROM with à Oracle legacy database, How set the sequence name to retrieve the primary key value ?
Like this example with ActiveRecord :
class Contract < ActiveRecord::Base
  self.table_name       = 'contrats_tiers'
  self.primary_key      = 'cont_trs_pk'
  self.sequence_name    = 'sq_cont_trs_pk'
end
Armin
@wuarmin
@vivian-maes @mainameiz The discussion-forum of rom-rb moved to https://discourse.rom-rb.org/. Please post your questions/issues there!