Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 09:46
    solnic synchronize #402
  • 09:46

    solnic on update-to-rom6

    [wip] stop requiring rom/compat (compare)

  • Jan 09 10:14
    solnic synchronize #402
  • Jan 09 10:14

    solnic on update-to-rom6

    WIP (compare)

  • Jan 09 10:13
    solnic synchronize #402
  • Jan 09 10:13

    solnic on update-to-rom6

    WIP (compare)

  • Jan 09 10:11
    solnic synchronize #402
  • Jan 09 10:11

    solnic on update-to-rom6

    WIP (compare)

  • Jan 07 19:19
    cllns commented #310
  • Jan 07 19:17
    cllns commented #310
  • Dec 21 2021 06:09
    cc-kawakami starred rom-rb/rom-sql
  • Dec 20 2021 10:56
    solenko commented #297
  • Dec 09 2021 15:25
    ianks added as member
  • Nov 26 2021 00:03
    nemuba starred rom-rb/rom-csv
  • Nov 09 2021 16:54
    mkiroshgl starred rom-rb/rom-rb.org
  • Oct 30 2021 18:36
    Mifrill starred rom-rb/rom-sql
  • Oct 24 2021 07:14
    wicky-info starred rom-rb/rom-sql
  • Oct 19 2021 14:51
    woarewe starred rom-rb/rom-sql
  • Oct 16 2021 12:09
    Lokideos starred rom-rb/rom-sql
  • Oct 15 2021 22:24
    jodosha starred rom-rb/rom-sql
Nikita Shilnikov
@flash-gordon
or ask Jeremy on the google groups
Mihai Radulescu
@mihairadulescu
yeah will check into sequel groups
Dawid Lenkiewicz
@dawidlenkiewicz
Hey is it possible to write this query without directly calling Sequel?
collection = collection.where { Sequel.|(*search_params.horsepower_ranges_map) }
this search_params.horsepower_ranges_map returns array of hashes like: [ { horsepower: 100..200 }, { horsepower: 500..600} ]
Viet (Drake) Tran
@tiev
@solnic Does rom-roda work with Rom v4?
Viet (Drake) Tran
@tiev
I've tried rom-roda with rom v4 and failed. Do you think the interface of rom-roda should change? Can I contribute to make it work with rom v4?
Vasily Kolesnikov
@v-kolesnikov
@tiev rom-roda looks outdated. But there isn't much sense to use this plugin. You can use rom and roda together without any additional libraries. For example: https://github.com/v-kolesnikov/elias/tree/feature/api_v1
Viet (Drake) Tran
@tiev
ah, it's dry-web-roda
it is promising
Tim Riley
@timriley
dry-web-roda has been retired, @tiev, so we won’t be updating it.
You’ll probably just want to update your app’s rom integration yourself, making whatever changes are required
Oskar Szrajer
@gotar
@tiev I'm using dry-web-roda, and it's working with ROM 4
I just made few changes to make it works
Piotr Solnica
@solnic
@tiev there's no need for rom-roda, I need to delete this repo. if you want to use rom + roda it's better to either set it up yourself or use dry-web-roda
Viet (Drake) Tran
@tiev
Thanks all.
Viet (Drake) Tran
@tiev
Hi Tim. I like functional oop architecture. Any specific problems that dry-web-roda gets retired?
Piotr Solnica
@solnic
@tiev we've started helping with Hanami and this is where our focus will be, not dry-web-roda. The plan is to make Hanami 2.0 work nicely with dry-rb, its alpha version already supports dry-system. We'll improve other integrations, like dry-validation, dry-view etc. too.
Dawid Lenkiewicz
@dawidlenkiewicz
Hey I've got a query that uses distinct on + order notation. It works well, but in the end I want to order results by some attribute and it looks like initial ordering is overwritten
Dawid Lenkiewicz
@dawidlenkiewicz

end of initial query:

ORDER BY \"car_model_id\", \"finance_rate_cents\"">>

after applying ordering like order { Sequel[column_name].send(order_direction, nulls: :last) }

the end of query changes to order specified above

can I somehow wrap it to force subquery ?
Dawid Lenkiewicz
@dawidlenkiewicz
something like this works:
relations[:offers].new(relations[:offers].dataset.select_all.from(collection.dataset)).order_by(
but doesn't look nice :) Maybe there is a better way?
Piotr Solnica
@solnic
@dawidlenkiewicz can you provide a script that shows this?
Dawid Lenkiewicz
@dawidlenkiewicz
yes, sorry it may not be easy to understand the way I wrote this

I guess the simple example is:

relation:

  def test
    select { %i(car_model_id score horsepower) }.distinct(:car_model_id).order(:car_model_id, :score)
  end
[1] pry(#<OffersRepository>)> relations[:offers].test
=> #<OffersRelation name=ROM::Relation::Name(offers) dataset=#<Sequel::Postgres::Dataset: "SELECT DISTINCT ON (\"car_model_id\") \"offers\".\"car_model_id\", \"offers\".\"score\", \"offers\".\"horsepower\" FROM \"offers\" ORDER BY \"car_model_id\", \"score\"">>

[2] pry(#<OffersRepository>)> relations[:offers].test.order(:horsepower)
=> #<OffersRelation name=ROM::Relation::Name(offers) dataset=#<Sequel::Postgres::Dataset: "SELECT DISTINCT ON (\"car_model_id\") \"offers\".\"car_model_id\", \"offers\".\"score\", \"offers\".\"horsepower\" FROM \"offers\" ORDER BY \"horsepower\"">>
I'm wondering what is the "proper" way to wrap the query
Piotr Solnica
@solnic
@dawidlenkiewicz so you want to append more columns for ordering?
Dawid Lenkiewicz
@dawidlenkiewicz
the end goal is SELECT * FROM ( SELECT DISTINCT ON ..... ORDER BY car_model_id, score) ORDER BY horsepower
so using a subquery
Piotr Solnica
@solnic
@flash-gordon ^^ subqueries are not yet supported OOTB, right?
Nikita Shilnikov
@flash-gordon
nah, not supported, mostly because it’s rarely needed
as in, why do you need a separate query for ordering?
Vasily Kolesnikov
@v-kolesnikov
@flash-gordon I just writing the same question :smile:
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)