Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 26 10:04
    chee-k starred rom-rb/rom-sql
  • Jun 14 20:47
  • Jun 01 05:15

    solnic on main

    Switch to peaceiris/actions-gh-… (compare)

  • May 28 10:20

    solnic on main

    Remove GA (compare)

  • May 27 16:41
    dependabot[bot] labeled #344
  • May 27 16:41
    dependabot[bot] labeled #344
  • May 27 16:41
    dependabot[bot] opened #344
  • May 27 16:41

    dependabot[bot] on bundler

    Bump rack from 2.2.3 to 2.2.3.1… (compare)

  • May 23 23:46

    dependabot[bot] on bundler

    (compare)

  • May 23 23:46
    dependabot[bot] closed #342
  • May 23 23:46
    dependabot[bot] commented #342
  • May 23 23:46
    dependabot[bot] labeled #343
  • May 23 23:46
    dependabot[bot] labeled #343
  • May 23 23:46
    dependabot[bot] opened #343
  • May 23 23:46

    dependabot[bot] on bundler

    Bump nokogiri from 1.11.4 to 1.… (compare)

  • May 23 08:32
    solnic milestoned #411
  • May 23 08:32
    solnic opened #411
  • May 23 08:32
    solnic labeled #411
  • May 23 08:32
    solnic labeled #411
  • May 20 15:51
S.Tamiya
@ablce9

I have a question here. Basically I have three tables and need to left-join two of them. SQL here MySQL [account]> select email,role,main_email from users left join tenants_users on (tenants_users.user_uuid = users.uuid) left join tenants on (tenants.main_email = users.email);.
I got this instead,

[86] pry(main)> db.from(:users).select(:email).left_join(:tenants_users, user_uuid: :uuid).select_append(:role).left_join(:tenants, main_email: :email)
=> #<Sequel::Mysql2::Dataset: "SELECT `email`, `role` FROM `users` LEFT JOIN `tenants_users` ON (`tenants_users`.`user_uuid` = `users`.`uuid`) LEFT JOIN `tenants` ON (`tenants`.`main_email` = `tenants_users`.`email`)">

I like to replace tenants_users.email with users.email.

I wonder how I can explicitly write left join tenants on (users.email = tenants.main_email) ???
Oskar Szrajer
@gotar
@ablce9 left_join(:tenants, { main_email: :email }, table_alias: :users) i guess
Nikita Shilnikov
@flash-gordon
this is falling back to sequel, rom-sql from master has first class support for it. ATM releasing a matter of a couple of months
Oskar Szrajer
@gotar
but that should do the job as I know
@flash-gordon and how new ROM support for this looks like?
Nikita Shilnikov
@flash-gordon
it's on the changelog
Oskar Szrajer
@gotar
ok :)
Nikita Shilnikov
@flash-gordon
there should be nice examples
Oskar Szrajer
@gotar
yeah :) nice one thx
S.Tamiya
@ablce9
@flash-gordon Thanks. I somehow figures using Sequel.lit(users.email).
ohh, sorry @gotar
Oskar Szrajer
@gotar
Sequel.lit() generally should never be used (all should be achievable in ROM, without calling Sequel directly)
S.Tamiya
@ablce9
Yeah, but this is one time only. The code is meant for a migration.
Nikita Shilnikov
@flash-gordon
I actually write migrations in pure SQL :)
data migrations I mean
S.Tamiya
@ablce9
The project I'm working on generally stores migration file around db/migration . Is that common to write pure SQL when doing migration?
Nikita Shilnikov
@flash-gordon
well, depends on your SQL skills :) Data migrations are kind of one-way anyway and I don't want anything between me and database during the migration. And it's usually faster
personally, I wrote a lot of SQL so this is a non-issue for me
S.Tamiya
@ablce9
I realized it's really tricky converting SQL code into Sequel. and what worse is Sequel is not that supportive I guess? so I come here and ask for helps and people here are really supportive, thanks.
Nikita Shilnikov
@flash-gordon
We discourage from Sequel when possible, our plan is provide people with the tools required for that
Sequel is sort of low level in general and leaks too much SQL related stuff
OTOH migrations is a different beast
esp data migrations
S.Tamiya
@ablce9
gotcha!
Ethan Turkeltaub
@ethnt
Hi guys, another question. I have a recursive relation: a country has many regions, which has many regions. is there a way to recursively get all of the regions of a country?
countries_repositories.aggregate(region: :region) gets the first two layers but not below that
Piotr Solnica
@solnic
@ethnt there's no special feature to cover this. You could write some smart query yourself to get it effectively.
Ethan Turkeltaub
@ethnt
@solnic Good to know, thanks :+1:
Ethan Turkeltaub
@ethnt
@solnic I guess in a similar vein, is there a recommendation for trees in ROM or just use self-referential associations?
Piotr Solnica
@solnic
I used tree extension in PG for that
Ethan Turkeltaub
@ethnt
If only I could use PG 🙃stuck on MySQL
Piotr Solnica
@solnic
@ethnt that's unfortunate, because the implementation in PG was like few lines of code, I really liked it
we even have a special type for ltree: https://github.com/rom-rb/rom-sql/blob/master/lib/rom/sql/extensions/postgres/types/ltree.rb it gives you custom API for queries like people.select(:name).where { ltree_tags.match_any(['Bottom', 'Bottom.Cities.*']) } :)
Mihai Radulescu
@mihairadulescu
hey guys did anyone experienced lately MySql connection has Gone away when using rom.rb in Aurora Db Mysql ?
Nikita Shilnikov
@flash-gordon
I don't think this kind of issues could be directly related to rom, although it's possible databases close connections after a certain timeout. I know that Sequel has a workaround for that and I'm pretty it sure you can use it with rom
assuming my guess is right ofc
Mihai Radulescu
@mihairadulescu
already have that connection validator in place.
Nikita Shilnikov
@flash-gordon
huh
so in any case I would look deeper, maybe search through sequel's issues for advice
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