Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Apr 02 13:30
    wmakley edited #314
  • Apr 02 13:26
    wmakley edited #314
  • Apr 02 13:25
    wmakley opened #314
  • Apr 01 10:32
    solnic commented #313
  • Mar 31 12:33
    MicMicMon commented #313
  • Mar 31 11:10

    rom-bot on gh-pages

    Deploy to GitHub pages (compare)

  • Mar 31 11:05

    solnic on master

    Remove rom-redis from the api l… (compare)

  • Mar 31 11:03

    rom-bot on gh-pages

    Deploy to GitHub pages (compare)

  • Mar 31 11:02

    solnic on master

    Update README.md Closes rom-rb… (compare)

  • Mar 31 10:57

    solnic on master

    Update how-to-build-an-adapter … Merge pull request #311 from km… (compare)

  • Mar 31 10:57
    solnic closed #311
  • Mar 31 10:54
    solnic commented #313
  • Mar 30 08:32
    MicMicMon opened #313
  • Mar 29 19:42
    MicMicMon opened #312
  • Mar 29 12:52
    kml opened #311
  • Mar 29 12:48
  • Mar 25 10:43

    rom-bot on gh-pages

    Deploy to GitHub pages (compare)

  • Mar 25 10:38

    solnic on master

    Fix typo of Sequel Merge pull request #310 from ad… (compare)

  • Mar 25 10:38
    solnic closed #310
  • Mar 25 10:34
    solnic commented #29
Dawid Lenkiewicz
@dawidlenkiewicz
yes I need separate query, because the "inside" query uses disctinct on with order, but the "real" ordering should be done outside
ok thx for the help
Nikita Shilnikov
@flash-gordon
window functions are “better” in this regard because they have inline order by
Armin
@wuarmin
Hello, is there a way to truncate all ROM::Relations? I need to truncate all tables after or before each integration-test.
Vasily Kolesnikov
@v-kolesnikov
In the one of my projects where I had two databases under the single ROM container I used to do the following:
TABLES = {
  main_db: rom.relations
              .select { |_, relation| relation.gateway == :main }
              .map    { |_, relation| relation.schema.name.dataset },

  second_db: rom.relations
                .select { |_, relation| relation.gateway == :second }
                .map    { |_, relation| relation.schema.name.dataset }
}.freeze

DatabaseCleaner[:sequel, connection: dbs[:second]]
  .strategy = :truncation, { only: TABLES[:second_db] }

DatabaseCleaner[:sequel, connection: dbs[:main]]
  .strategy = :truncation, { only: TABLES[:main_db] }
Piotr Solnica
@solnic
would be nice to add a built-in solution for this
Nikita Shilnikov
@flash-gordon
tbf I always wonder why people won’t use transactions
Vasily Kolesnikov
@v-kolesnikov
Because of capybara?)
Nikita Shilnikov
@flash-gordon
nah, not an excuse, you can have a shared connection, that’s what I do
    options = {
      test: true,
      single_threaded: persistence.config.env == :test,
      after_connect: inject_pub_connections,
      max_connections: 30
    }
my config
single_threaded ensures the same connection is used by the web server and your test code
you only need to care all http requests are finished before you query database otherwise the connection will blow up (obviously)
Vasily Kolesnikov
@v-kolesnikov
Actually I don't use capybara in my projects. But I prefer to develop in test environment and sometimes I need to explore database state, that is my case.
Piotr Solnica
@solnic
@flash-gordon there are setups where transactions don't work
that's why we need to support various cleaning strategies
Nikita Shilnikov
@flash-gordon
before rushing to it I’d like to know them :) One example is well-known to me, it’s Oracle and non-transactional DDL, what about others?
otherwise providing proper API is guessing
Vasily Kolesnikov
@v-kolesnikov
Piotr Solnica
@solnic
in my current project we have CI configured to use sqlite, using transactions didn't work
I'm just talking about having database cleaner support that works OOTB
so that people can do DatabaseCleaner[:rom_sql]
Nikita Shilnikov
@flash-gordon
@v-kolesnikov yeah I know, but what I meant is real shit, calling DDL from stored procedure where you store your business logic ;) For other cases non-transactional DDL is acceptable, you’re not supposed to call it in tests. In most cases
@solnic does sqlite support transactions? I guess it should
Vasily Kolesnikov
@v-kolesnikov
It just an example, I don't argue.
Piotr Solnica
@solnic
@flash-gordon it does, but it does not work with nested transactions, at least the combination of minitest + database cleaner + sqlite + transactional strategy did not work for me
anyhow, my main point is to have official support for database cleaner, it's the de facto standard and it sucks people need to use :sequel to use it
Nikita Shilnikov
@flash-gordon
I got your point, my point is every time I ask why people use database_cleaner they don’t give me a satisfying answer. OTOH it’s not that I often ask :)
and sequel is not directly involved, I bet you should know how connection pooling works in your app regardless who does the machinery
it’s not that I’m against database_cleaner, I just have never seen a point
Jeff Dickey
@jdickey
Agreed. We started out loving database_cleaner, but we now avoid it because it makes life in Docker more of a special case than we're happy with
Yes, there's a highly reliable workaround, but it's a non-obvious workaround — especially when the error messages you start out chasing lead you in different directions entirely
Armin
@wuarmin
Interesting discussion. I'm using rom
Armin
@wuarmin
sql through hanami-model. The code base is big and we are using multiple postgresql db's and schemas. Hanami does not support multiple db's and schemas at the moment, so just the main db with its public schema is handled by hanami repos. Because of this, the transactional approach does not work everywhere.
Grzegorz Wcisło
@grzegorz-wcislo
Is it possible to combine results from relations from two different adapters (sql and elastic)?
It is a one to one relation
Vasily Kolesnikov
@v-kolesnikov
It isn't native supported yet.
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 >