Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Sep 17 10:30
    kwando closed #15
  • Sep 12 16:29

    cflipse on v2.2.0

    (compare)

  • Sep 12 16:28

    cflipse on master

    bump (compare)

  • Sep 12 15:56

    cflipse on master

    update rubocop config (compare)

  • Sep 12 15:53

    cflipse on master

    Update generated files to be co… Address rom-5 deprecation warni… Merge pull request #107 from ro… (compare)

  • Sep 12 15:53
    cflipse closed #107
  • Sep 12 15:53
    cflipse closed #103
  • Sep 12 14:55
    cflipse opened #107
  • Sep 12 14:55

    cflipse on fix-generators

    Update generated files to be co… Address rom-5 deprecation warni… (compare)

  • Sep 12 14:41

    cflipse on master

    check options as well Verify we can extract the defau… rubocop and 4 more (compare)

  • Sep 12 14:41
    cflipse closed #106
  • Sep 12 14:41
    cflipse opened #106
  • Sep 12 14:28

    cflipse on multiple-databases

    check options as well Verify we can extract the defau… rubocop and 3 more (compare)

  • Sep 12 13:43

    cflipse on master

    fix spec (compare)

  • Sep 11 16:40
    frostmark commented #104
  • Sep 11 15:58

    cflipse on master

    separate a uri builder from the… restructure so configuration is… Rails 6 changes `configurations… and 3 more (compare)

  • Sep 11 15:58
    cflipse closed #105
  • Sep 11 15:58
    cflipse closed #104
  • Sep 11 15:29
    cflipse synchronize #105
  • Sep 11 15:29

    cflipse on handle-rails6-config

    And actually verify that we're … (compare)

Nikita Shilnikov
@flash-gordon
likely it’s related to how distinct on works
for instance, window functions may require subqueries for this because they’re evaluated after ordering IIRC
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 :)