havenwood changed the topic of #ruby to: Ruby 3.3.0, 3.2.2, 3.1.4 https://www.ruby-lang.org | Rules https://ruby-community.com | Logs https://libera.irclog.whitequark.org/ruby
whysthatso125070 has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
whysthatso125070 has quit [Quit: The Lounge - https://thelounge.chat]
whysthatso125070 has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
Paris has quit [Quit: quit]
jenrzzz_ has joined #ruby
Al2O3 is now known as gosub
gosub is now known as GoSub
GoSub has quit [Quit: Good mourning, good after nun, g'nite, and goober evenings.]
Al2O3 has joined #ruby
jenrzzz_ has quit [Ping timeout: 264 seconds]
jenrzzz has quit [Ping timeout: 264 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 255 seconds]
gr33n7007h has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
Al2O3 has quit [Changing host]
Al2O3 has joined #ruby
dstein64- has joined #ruby
FullMetalStacker has quit [Ping timeout: 260 seconds]
FullMetalStacker has joined #ruby
dstein64 has quit [Ping timeout: 264 seconds]
dstein64- is now known as dstein64
micro has quit [Remote host closed the connection]
ua_ has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
fercell_ has joined #ruby
fercell has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 264 seconds]
jenrzzz_ has joined #ruby
ua_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 260 seconds]
Vonter has joined #ruby
Vonter has quit [Quit: WeeChat 4.1.2]
Vonter has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
Al2O3 has quit [Quit: Good mourning, good after nun, g'nite, and goober evenings.]
Al2O3 has joined #ruby
Al2O3 has quit [Client Quit]
Al2O3 has joined #ruby
Al2O3 has quit [Changing host]
Al2O3 has joined #ruby
Al2O3 has quit [Client Quit]
Al2O3 has joined #ruby
Al2O3 has quit [Changing host]
Al2O3 has joined #ruby
Vonter has quit [Ping timeout: 256 seconds]
Vonter has joined #ruby
jenrzzz has joined #ruby
Paris has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
jenrzzz_ has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
TomyLobo has quit [Ping timeout: 276 seconds]
jenrzzz_ has quit [Ping timeout: 252 seconds]
jenrzzz has quit [Ping timeout: 264 seconds]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 260 seconds]
jenrzzz has quit [Ping timeout: 260 seconds]
jenrzzz_ has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
Al2O3_ has joined #ruby
xHire has joined #ruby
jenrzzz has joined #ruby
Al2O3 has quit [Ping timeout: 245 seconds]
Al2O3_ has quit [Client Quit]
Al2O3 has joined #ruby
Al2O3 has quit [Client Quit]
jenrzzz has quit [Ping timeout: 245 seconds]
<xHire> hello! :·) I’m pondering upon bundler’s classic error “You have already activated base64 0.1.1, but your Gemfile requires base64 0.2.0. Since base64 is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports base64 as a default gem.” I looked around a lot, but I’m not sure what to do. The message is kinda misleading, since bundler itself doesn’t “support” certain gems as default
<xHire> gems (or I misunderstood bundler’s code, also possible). Anyway, since rails list base64 as their dependency and I want to support multiple versions of Ruby (so I can’t just pin certain version of base64 in my Gemfile), I thought that perhaps bundler-ecology plugin would do what I need (i.e., exclude base64 from Gemfile.lock). However, it just causes a failure, because rails list base64. Is there something I can do in my application to solve the 0.1.1 vs.
<xHire> 0.2.0 problem?
jenrzzz has joined #ruby
jenrzzz_ has quit [Ping timeout: 252 seconds]
jenrzzz has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
grenierm has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
Paris has quit [Ping timeout: 245 seconds]
Vonter has quit [Ping timeout: 268 seconds]
Linux_Kerio has joined #ruby
jenrzzz_ has quit [Ping timeout: 260 seconds]
Munto has quit [Quit: Leaving]
xdminsy has joined #ruby
jenrzzz has joined #ruby
grenierm has quit [Quit: Client closed]
jenrzzz has quit [Ping timeout: 264 seconds]
grenierm has joined #ruby
Vonter has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 276 seconds]
Vonter has quit [Ping timeout: 276 seconds]
Vonter has joined #ruby
jenrzzz has joined #ruby
FullMetalStacker has quit [Read error: Connection reset by peer]
jenrzzz_ has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
jenrzzz_ has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
_ht has joined #ruby
eoli3n has joined #ruby
<eoli3n> Hi
<eoli3n> i use jekyll and a plugin which is jekyll-gallery-generator. I used it with 2.7.5 locked version, i build the site locally and push to github and gitlab pages. Gitlab doesn't support ruby2.X anymore, then i'm trying to upgrade to ruby 3.X
<eoli3n> using latest ruby 3.3.2 (voidlinux), i get an error when building the site because of the removal of exists alias
<eoli3n> i opened an issue to the maintainer to fix the code. But now i'm trying to get my site build with ruby 3.1.3 (latest BEFORE 3.2 that i can install with rbenv)
<eoli3n> when i "rbenv install 3.1.3 --verbose" i get some errors at the end
<eoli3n> here is the full log : https://0x0.st/HEkD.log
<eoli3n> i tried all pristine commands that the log advices to try
<eoli3n> i think that everything is related to the first warning : "The Ruby openssl extension was not compiled."
<eoli3n> checking on github, i see that ruby 3.1.3 should be compatible with openssl3
<eoli3n> i'm not a ruby user outside of jekyll, so i don't master anything, just hardly trying to fix issues one by one
<eoli3n> i'm not even sure of my diag, here's the error i get on gitlab : https://gitlab.com/eoli3n/eoli3n.gitlab.io/-/jobs/5838857851 (is that public ?)
<eoli3n> as said, i build the site locally then push to *-pages, so i don't get why ruby is used pages side
<eoli3n> this seem to confirm that my solving path is the right one : https://stackoverflow.com/a/68801553
<eoli3n> so then, back to my main problem : how do I fix my rbenv install of ruby 3.1.3 ?
c10l has quit [Ping timeout: 276 seconds]
c10l has joined #ruby
<eoli3n> i just rm -Rf ~/.gem/ruby/, rebuilding
CrazyEddy has joined #ruby
<eoli3n> changed nothing
<eoli3n> now i don't knwo what to try
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
grenierm has quit [Ping timeout: 250 seconds]
infinityfye has joined #ruby
Paris has joined #ruby
alip is now known as syd
syd is now known as sydbot
sydbot is now known as alip
Paris has quit [Quit: quit]
<rapha> did you try to uninstall _all_ versions of _all_ gems (gem uninstall -aIx), eoli3n? i had to do that once. the second thing i can think of is to migrate away from rbenv and try asdf with its ruby plugin. trying rvm might also work where the other two won't, but if i have a choice, i'm asdf all the way these days.
<rapha> (a lot of things can go wrong when building a package from scratch, especially if a lot of dependencies are involved, so swapping out the scripts that do the building is a good shot)
Al2O3 has joined #ruby
Al2O3 has quit [Changing host]
Al2O3 has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
TomyLobo has joined #ruby
fcser has quit [Quit: zzzzz]
fcser has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
fcser has quit [Quit: zzzzz]
fcser has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
<adam12> xHire: Make sure you're on the latest bundler, since there have been improvements in how it handles default gems.
<adam12> eoli3n: whats your current situation with ruby/rbenv?
<eoli3n> rapha: lets try
<eoli3n> adam12: same as i explained
<adam12> eoli3n: You could just monkeyptch back `exists?` if it's easier for you.
<eoli3n> what does that mean ? monkeypatch ?
<adam12> eoli3n: re-open the class that removed the alias and put it back in, as if it never even happened.
<eoli3n> rapha: i want only to remove gems installed as user, what's the way to ?
<eoli3n> because i don't want to remove something a distro package use
<eoli3n> adam12: i don't want to patch ruby, seems the hard way
<adam12> eoli3n: It's 3 lines, but we'd need to figure out where to insert it.
<adam12> eoli3n: have you tried deleting .rbenv/versions/3.1.3 AND .gems/ruby ?
<eoli3n> i tried deleting only .gems/ruby
<adam12> You're also missing libyaml, according to one of the build logs you posted.
<eoli3n> libyaml-devel is installed, i checked that
<eoli3n> i don't know why it still complains
<adam12> eoli3n: if you switch back to using ruby from your distro, what's the error exactly, and what command do you run?
<eoli3n> adam12: i run `bundle exec jekyll build`
<eoli3n> let me paste the full log
<eoli3n> adam12: i added full log to the issue
<adam12> eoli3n: Make a file in your blog directory called file-exists.rb with these contents: https://gist.github.com/adam12/decce8f6d80fd1e2571d52be0da66a17
<adam12> then try this: `RUBYOPT="-r./file-exists" bundle exec jekyll build`
<eoli3n> it works
<eoli3n> let's keep that workaround instead of debugging 3.1.3 install
<eoli3n> thanks adam12
<adam12> No problem.
<eoli3n> adam12: i still get a problem on gitlab pages
<eoli3n> do you see this ? not sur if it is public
<adam12> eoli3n: I see the error. Where is the gitlab ci config for this? I looked but didn't see it.
<adam12> Your running into this, I think: https://github.com/rubygems/rubygems/issues/7329
<adam12> Oh, I found it. Different branch
<adam12> Yeah.
<eoli3n> i see that giltab ci use ruby 2.7 docker image
<adam12> force the bundler version. `gem install bundler -v 2.4.22` instead
<eoli3n> hm ok
<adam12> (inside your .gitlab-ci.yml file)
<eoli3n> yep got that part
<eoli3n> pushing
<eoli3n> hey, I am using ruby:2.7 in the gitlab ci
<eoli3n> maybe i should just update this to ruby:3.2
<eoli3n> i'll try next
<adam12> eoli3n: You could, and it would probably save your sanity to run the same version, but you'll need to get the monkeypatch into CI too
<adam12> Which isn't an issue but just something to be aware of.
<adam12> It looks like your build is working.
<eoli3n> hm, here is a part i don't remember
<eoli3n> to be able to use a custom plugin, i needed to automate in a pre-push, the build locally, then push the build directly in the right branch
<adam12> btw, I love the tree looking output on your homepage. I just found out yesterday that tree(1) supports an HTML output option.
<eoli3n> so AFAIR, i don't build ci side
<eoli3n> BUT
<eoli3n> in gitlab-ci for exemple i can see bundle exec jekyll build
<eoli3n> adam12: thanks
<eoli3n> and the tree output was built with css
<adam12> Neat.
<eoli3n> ok the fix of bundle install worked
<eoli3n> lets try to remove the forced version of bundler and use ruby3.2
<adam12> I'm taking off for lunch and family time. Good luck. I might be back around later.
<eoli3n> yep, thanks a lot for your help
<eoli3n> adam12: everything's great now, with your workaround in the pipeline
<eoli3n> thanks again
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
Areoskin has joined #ruby
Areoskin has quit [Quit: Leaving.]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 256 seconds]
jenrzzz has quit [Ping timeout: 256 seconds]
ionface has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
Vetheon has joined #ruby
<Vetheon> Hey guys, out of curiosity, what are your preferred data-structures for getting, modifying, then replacing a series of objects in a collection quickly? I'm dealing with a pretty large dataset, and hashes aren't really doing the trick. Any ideas?
jenrzzz has joined #ruby
Vetheon has quit [Read error: Connection reset by peer]
jenrzzz_ has joined #ruby
Vetheon has joined #ruby
<ox1eef_> Ruby builtins include Array, Hash, and Set. I can't think of any others. Can you provide more details ? Your question is a bit vague to provide an answer.
<ox1eef_> You could always drop down to C as well.
<Vetheon> So, I have a group of objects with a series of parameters. Currently, I'm converting each one to a hash so I can modify the parameters with some math, but when the amount of objects surpasses like... 15k the whole things falls apart because of the sheer amount of math.
<Vetheon> I've optimized calls as best I can, but there's still a lot of math going on. So I'm trying to find other ways to optimize
<ox1eef_> Have you thought about distributing the workload across multiple processes ?
jenrzzz has quit [Ping timeout: 245 seconds]
<Vetheon> I have indeed, but I've been bumping against Rubys GIL. I need the main thread to remain running while the math is ongoing.
<ox1eef_> Processes are run in parallel. Only threads have the GIL.
jenrzzz_ has quit [Ping timeout: 252 seconds]
<Vetheon> Ruby has such a system in the stdlib, or do I need a Gem?
<Vetheon> Because I've never even heard of Processes in parallel in Ruby. Only threads and fibers
<ox1eef_> It is builtin. Kernel#fork. You will likely need a mechanism for IPC. I happen to have written a gem for that: https://github.com/0x1eef/xchan.rb#readme but there's other options - for example, that gem just uses an unbound UNIXSocket.
<ox1eef_> fork should work so long as you're not on Windows, or JRuby.
<Vetheon> I guess I could also just drop down to C. The problem is I've never used a C Extension in Ruby before. So I'd have to learn how it all works, which means wiki reading lol
<ox1eef_> C extension API is pretty nice and easy, as long as you're not doing anything too complex.
<Vetheon> Well I'm doing trig math lol
<Vetheon> and a lot of calc
<Vetheon> Thx
<ox1eef_> Those are the bookmarks I keep for C stuff in Ruby.
<Vetheon> Oooh you can extend the interpreter too. That's some handy info. Thanks oxleef_
<ox1eef_> I think distributing the workload with fork could work as well, communicating the result with the main process would be the hardest part (for me at least).
<ox1eef_> No worries.
<Vetheon> See, I thought about forking into many child processes, but I couldn't come up with a nice way to communicate
<Vetheon> I need the system to be as portable as possible, so I'm trying to limit what Gems I'm depending on. I think right now it's basically just one, for SQL
<ox1eef_> xchan makes that easy, but there's only so much data you can write before the next write blocks, and you *must* read before another write can happen.
<ox1eef_> Right, and fork is incompatiable with Windows, JVM (jruby).
<Vetheon> Well, while it'd be great to run on Windows, I think targeting WSL/Mingw is a better idea, so that's my plan
<ox1eef_> Roger
<Vetheon> Then at least I don't need to deal with windows jank security policies and stuff
<Vetheon> But also the final version of this won't be written in Ruby. Ruby is just the lang I chose for prototyping
<ox1eef_> Ah okay. I believe Ruby can bind to Rust these days too. Might be useful to know.
<Vetheon> That is indeed good to know. Afaik FFI can be used to interface with just about anything no?
<Vetheon> Really what would be great would be some bindings for CUDA that aren't either old af or not up-to-date with CUDA
<ox1eef_> Tradtionally I think dlopen is used, and so the interface has been C, but there's a special create that binds to Ruby.
<Vetheon> Having GPU accel would be awesome
<ox1eef_> crate*
<ox1eef_> Useful too maybe, if you had a shared library doing the expensive stuff... it is a ruby builtin: https://github.com/ruby/fiddle
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 255 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
xdminsy has quit [Ping timeout: 245 seconds]
jenrzzz has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz has quit [Ping timeout: 276 seconds]
jenrzzz_ has quit [Ping timeout: 276 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 245 seconds]
km has joined #ruby
jenrzzz has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 268 seconds]
whysthatso125070 has quit [Quit: The Lounge - https://thelounge.chat]
whysthatso125070 has joined #ruby
infinityfye has quit [Quit: Leaving]
<adam12> Depending on what it is, you can use druby + rinda to share a workload as well. Set up a druby service, fork, reconnect back to the service, pop off entries from the rinda service. Beware some operations can be O(n)
<ox1eef_> Yep. And both of those are builtin / stdlib.
<ih8u> happy new year everyone
<ox1eef_> Same to you.
<ih8u> is it true that Sequel's `where` statement doesn't work with pg_array?
<ih8u> or am i missing something?
<ox1eef_> My journey with Sequel was short-lived. adam12 might know :)
<ih8u> i can do `DB[:accounts].where(id: [1, 2, 3])` and i get accounts with ids 1, 2, and 3
<ih8u> but if i try that with a pg_array it doesn't work
<ox1eef_> This will generate 'accounts.id IN (1,2,3)' AFAIK, and I think pg array extension has its own syntax, which should always be accessible via string syntax.
<adam12> ih8u: You probably need the postgres operator? Doesn't it use -> or similar?
<adam12> Happy new year (almost, for me)
<ox1eef_> Same. 7PM here.
<adam12> Oh it uses a subscript.
<ih8u> what's a subscript?
<ox1eef_> subscript is like: SELECT schedule[:][1:1] FROM sal_emp WHERE name = 'Bill';
jenrzzz has joined #ruby
<ox1eef_> It seems with that extension / plugin you should have first-class array support, but I don't really know for sure.
<ih8u> i'm using that extension, that's why i have a pg_array to work with in the first place
<ox1eef_> Try: .where(id: Sequel.pg_array([1,2,3]))
<ih8u> but now i'm trying to select all rows which have an id in array of integersi already tried that
<ih8u> whoops
<ih8u> ox1eef_: i already tried that
<ih8u> as an explicit test and with the original pg_array object as a variable
<ih8u> but it returns error `PG::UndefinedFunction: ERROR: operator does not exist: integer = integer[]`
jenrzzz_ has joined #ruby
<adam12> DB[:table].where { Sequel.pg_array_op(:id).any =~ [1, 2, 3] }
jenrzzz has quit [Ping timeout: 256 seconds]
<adam12> Make sure you also load `pg_array_op` into Sequel. `Sequel.extension :pg_array_op`
asc has joined #ruby
<ih8u> (:
<ih8u> `PG::SyntaxError: ERROR: syntax error at or near "ANY"`
<ih8u> `LINE 1: ...ELECT count(*) AS "count" FROM "accounts" WHERE (ANY("id") ...`
<adam12> Bummer. I wasn't sure about that IN statement.
<adam12> What's the working SQL if you wrote it by hand?
jenrzzz has joined #ruby
constxqt_ has quit [Ping timeout: 256 seconds]
<ih8u> SELECT * FROM artists WHERE (id IN (1, 2))
<ox1eef_> IN won't work AFAIK, you need to use a syntax described in that link.
<ox1eef_> But I'd be surprised if the extension didn't handle it in a nicer way.
<ih8u> that's what `Artist.where(id: [1, 2])` (and which i know works and am trying to replicate with a pg_array)` yields, according to the link i stole it from
<ox1eef_> Right, but IN is a different syntax that's used on regular columns, not an array column.
<adam12> Maybe this will help?
<adam12> I gotta run. I couldnt' get it working in my mock sequel locally but it might not know how to do it without a real pg instance backing it.
<ox1eef_> Nice.
<ox1eef_> Btw, are you sure you want the id column to be an array ? That seems really odd.
<ih8u> i think you've misunderstood what i'm trying to do
<ih8u> i have an array of integers
jenrzzz has quit [Ping timeout: 245 seconds]
jenrzzz_ has quit [Ping timeout: 245 seconds]
<ih8u> and i want every row with an id contained within that array
constxqt_ has joined #ruby
<ih8u> so if i have [1, 2, 3], i want to select ids 1, 2, and 3
<ox1eef_> Ahhh. I see. And 'id' is a regular primary key column ? Because you don't even need pg_array for this. That should be covered by IN.
<ih8u> yes, and yes
<ox1eef_> Hrm.
<ih8u> i've already confirmed it works as expected with a normal array
<ih8u> but i have this array saved in another table
<ox1eef_> You want it to work with a pg array ? Then I think you ought to cast it to a regular Ruby array first.
<ox1eef_> Try .to_a, .to_ary
<ih8u> when i access it from sequel, it gives me a pg_array
<ox1eef_> That makes sense. It should just be a matter of unboxing the pg array into a regular Ruby array.
<ih8u> where did you find those methods?
<ih8u> works perfectly
<ox1eef_> Those are common Ruby methods for casting an object to an array. And great.
<ih8u> i knew somehow or other i could convert it to a regular array
<ih8u> and use it that way
<ih8u> easier than wrestling with more complex syntax
jenrzzz has joined #ruby
<ih8u> but i wanted to make sure i wasn't missing something
<ox1eef_> I think that's probably all there is to it.
<ih8u> seems weird that syntax wouldn't work with PGArray
<ox1eef_> I agree. But there could be a good reason for it. I don't really know Sequel that well.
Pixi` has joined #ruby
<ih8u> does to_a copy to a new object?
jenrzzz_ has joined #ruby
<ih8u> it must, right?
<ox1eef_> Generally yes, I think so.
<ox1eef_> There's exceptions: Array#to_a returns the same array, for example.
constxqt_ has quit [Ping timeout: 264 seconds]
<ih8u> I mean, it's not really a big deal, but potentially could be if the arrays start getting bigger
<ih8u> i guess i'd have bigger problems at that point
Pixi has quit [Ping timeout: 264 seconds]
<ox1eef_> It would not be a deep copy, the elements themselves are the same, and I would cross that bridge when if I end up there.
<ih8u> i should talk to a real db specialist about these things
<ih8u> i feel like i know just enough to be extraordinarily dangerous
<ox1eef_> They're very Ruby-specific questions rather than at the DB-level.
<ih8u> well, i mean about solving this problem in general
<ox1eef_> Generally, to_a returns a new array, and all of the elements would be references to objects already in memory, they're not copied.
<ih8u> like, db dudes would probably not like my relations
jenrzzz has quit [Ping timeout: 264 seconds]
<ox1eef_> IME best way to learn is by doing.
<ih8u> indeed
<ih8u> here i am
<ox1eef_> xD
jenrzzz_ has quit [Ping timeout: 252 seconds]
<adam12> DB[:table].where { Sequel[:id] =~ Sequel[:other_table][:other_column].pg_array.any
constxqt_ has joined #ruby
<adam12> (need `DB.extension(:pg_array)` and `Sequel.extension(:pg_array_ops)`)
<adam12> SQL output looks right...
<adam12> SELECT * FROM "table" WHERE ("id" = ANY("other_table"."other_column"))
<adam12> I rarely use array[] for things like this, unless postgres acquires fk support for arrays (then I might consider it)
<ih8u> i was wondering about that exact thing, actually
<ih8u> it's unlikely to become an issue for this particular use case, but it nags at me on principle
<ih8u> how would you model this?
<ih8u> i guess it's a one-to-many relationship?
<ih8u> say there's a list of albums
<ih8u> and a list of people
<ih8u> people can have many different favorite albums
<ih8u> so right now i'm using an integer[] column in the person table that contains the primary keys of all that person's favorite albums
<ih8u> but, like, if an album got deleted or moved or something, there would be no way to know that with this model, right?
<ox1eef_> In the traditional model, you'd probably have a join table, where there is a person_id & album_id. That way you can associate many people with the same album.
Vetheon has quit [Quit: Leaving.]
constxqt_ has quit [Ping timeout: 245 seconds]
<ih8u> my search keeps giving me results for merging two tables together
<ih8u> could you point me at some relevant literature?
<ox1eef_> I don't know how it works in Sequel, only ActiveRecord, but essentially there are three tables: persons, albums, and a join table, let's call it persons_albums for lack of a better term.
<ih8u> and/or give me a glimpse of what that would look like?
<ox1eef_> The join table has two FKs, one for an album, another for a person.
<ox1eef_> It sounds like what you are looking for, but your approach is different.
<ox1eef_> That looks like the Sequel equivalent.
<bougyman> That is correct.
constxqt_ has joined #ruby
<ih8u> so the strategy is to have an intermediate table that, for each favorite album of each person, contains the foreign keys of both of those tables
<weaksauc_> yeah
jenrzzz has joined #ruby
<ih8u> in that example, what happens to a "favorites" row when the album it references gets deleted?
<ih8u> or, i don't know, moved to another table or has its id changed?
<weaksauc_> that's on you to figure out
<ih8u> i'm not really sure the extent of foreign keys' power
<ih8u> i think i'm confused as to what a foreign key actually does
<ox1eef_> You can add a constraint that would not allow the album be deleted while there is a FK reference to it, or you could delete all those favorites when the album is destroyed. It is really up to you how you want to handle it.
constxqt_ has quit [Ping timeout: 256 seconds]
Pixi__ has joined #ruby
<weaksauc_> ih8u https://www.cockroachlabs.com/blog/what-is-a-foreign-key/ good overview of what they are and what they do and don't do
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
<ih8u> thank you, i will give that a read
<ih8u> but the short of it is that this intermediate-table approach would be more efficient than my current approach?
<ox1eef_> You can also add a unique index, so the same person can't favorite the same album twice. I think that'd be tricky to do with a pg array.
<ox1eef_> I would say, more solid.
<weaksauc_> yeah way more solid
<ih8u> what's a unique index
<weaksauc_> more examples out there too
Pixi` has quit [Ping timeout: 264 seconds]
<weaksauc_> you can stipulate that there exists only one pair of (user id, album id) in the join table
<weaksauc_> which is enforced at the db level
<ih8u> i see
<ih8u> seems some very smart people have spent a lot of time and effort solving for a lot of use cases
<ih8u> like it or not, i guess i'm in db admin now, so i'd better read up on this
<weaksauc_> indexes are also things that you can use to make the searches faster
<ih8u> how so?
<weaksauc_> yeah tons of really, really smart people have devoted their lives to making dbs efficient
xlymian has joined #ruby
<weaksauc_> it basically creates a sorted list based on some columns that it can efficiently look up
<weaksauc_> (really 10k foot view)
<ih8u> i should probably just read through the psql docs page by page (they seem pretty well-written)
<ih8u> what's the use of array columns, broadly?
<ih8u> what if an album has tags that you can search for?
jenrzzz has quit [Ping timeout: 256 seconds]
constxqt_ has joined #ruby
<weaksauc_> not 100% sure on the why of array but it gives you an option
<ih8u> right now i have the varchar "tags" column, which is a space-seperated list of tags, and full-text search through that
<ih8u> would an array be a better use for that?
<ih8u> or something else?
<weaksauc_> the pgsql docs assume you have a fairly strong working knowledge of dbs
jenrzzz has joined #ruby
<ih8u> oh, well, i obviously don't lol
<ox1eef_> Tags are often implemented with the same model we discussed in regards to persons / albums. There's a join table that joins a tag to an album.
<ih8u> so you have a "tags" table?
<ih8u> hm
<weaksauc_> yup
<ox1eef_> Tags table, Tagging table (tag_id, album_id), albums table.
<ih8u> i guess i'm just hesitant to create new tables
jenrzzz_ has joined #ruby
<ih8u> because i feel like i'm creating a bunch of overhead
<weaksauc_> it's the way sql was meant to work
<ih8u> i guess i need to abandon that thought
<adam12> _could_ use the array type here, if tag remains super primitive (list of strings). I've done it in past, since lots of tags aren't super generic and people tag things all sorts of random, so I don't think 3NF could apply here.
<ih8u> stop thinking of tables as spreadsheets
<adam12> I find most projects work better with _more_ tables and models.
<adam12> An easy giveaway is a prefixed table.
<adam12> s/table/column
<adam12> Once you start prefixing columns, it probably should have been another table/model.
<ih8u> what's 3nf?
<adam12> bbl
<weaksauc_> db philosophy makes it so that repeated data is a sin
<ih8u> i'm a fan of dry
<ih8u> but it occurs to me that more tables = more implementation requirements
jenrzzz_ has quit [Ping timeout: 264 seconds]
constxqt_ has quit [Ping timeout: 245 seconds]
Paris has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
<ih8u> going back to the tags example, if i used the intermediary approach, i'd have to implement some means of abstracting and handling all the necessary insertions, otherwise tagging my albums would get *really* tedious
jenrzzz has joined #ruby
<ih8u> i guess it's one of those things you have to consider at scale
<weaksauc_> probably a good overview
<ih8u> thank you, i appreciate the link
<weaksauc_> i mean yeah you'd have to abstract it a bit
<weaksauc_> what are you trying to do?
jenrzzz_ has joined #ruby
<ih8u> tag some albums lol
<ih8u> i'm not doing anything terribly complex
<weaksauc_> i mean what's the end goal here? website? app? using the db some other way?
<ih8u> website and app
<ih8u> i'm using roda to build out the website, and eventually api
<ih8u> so the website and app can be driven from the same place
<weaksauc_> there a reason for roda over rails?
<ih8u> rails is too opinionated
<ih8u> i clash with it
<ih8u> i've bounced off of rails like ten times over the last decade
jenrzzz has quit [Ping timeout: 268 seconds]
<weaksauc_> i see
<ih8u> roda makes more sense to me
<weaksauc_> it's just that something like this is rail's bread and butter kinda app
<ih8u> yeah, i know
<ih8u> but i just don't get along with it
<weaksauc_> i haven't heard any bad things about roda though so i'm sure you'll be fine
asc has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jenrzzz_ has quit [Ping timeout: 255 seconds]
<ih8u> i'll tell you what i really hate is web dev
<ih8u> especially front-end
<ih8u> what an insane nightmare
<ih8u> it has been a learning experience for me, and i have to say that that is just straight up unpleasant
<weaksauc_> there's a lot to knowing it
Paris has quit [Quit: quit]
constxqt_ has joined #ruby
<ih8u> now i've got some reading to do
constxqt_ has quit [Ping timeout: 255 seconds]
jenrzzz has joined #ruby
asc has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]