jdev - 2024-04-17

  1. MSavoritias (fae,ve)

    sql noob question: how do you add a relation to an existing message in your db? like a reaction or a message

  2. MSavoritias (fae,ve)

    i know the basics of SQL but i am struggling with the mental model

  3. MSavoritias (fae,ve)

    also apparently there is an object variant of sql

  4. lovetox

    google "SQL Join"

  5. lovetox

    search "SQL Join"

  6. lovetox

    you have a message table, and a reaction table, both tables have a message-id column, with SQL Join you can tell the database to "join" both tables and return data from both table in one result

  7. MSavoritias (fae,ve)

    ah and i see join just filters doesnt deletes. makes sense

  8. MSavoritias (fae,ve)

    heh thats why ids in group chats are so important

  9. MattJ

    MSavoritias (fae,ve), another key word you might want to look up is "foreign key"

  10. MattJ

    Okay, two words ;)

  11. MSavoritias (fae,ve)

    ah that makes sense with the relational terminology now

  12. moparisthebest

    Foreign keys are one of those things that are a needed concept but in real life the implementation is almost never used because it's a huge footgun, and some major DBS even lie about having an implementation lol

  13. MSavoritias (fae,ve)

    so i manually join everything? :( ....

  14. moparisthebest

    No, joins are very useful but unrelated to the foreign key implementation that some dbs give you

  15. moparisthebest

    By implementation I mean actually declaring foreign keys and doing cascading deletes and such

  16. Stefan

    I started to work on a db which will store the messages as raw data and use db trigger to build a kind of "functional"-view of a chat. It's just a prototyp, not sure if it will be a good idea. Anyway, I can share the ddl script.

  17. singpolyma

    moparisthebest: I mean, this is an area of hot contest I guess? I use foreign keys all the time, very useful. But I know there are some out there who don't even use DB side validations and prefer to do race conditions in the code instead 🤷‍♂️

  18. MSavoritias (fae,ve)

    wtf. i would expect nothing less than a db to be functional/atomic completely

  19. MSavoritias (fae,ve)

    it either works or it doesnt

  20. singpolyma

    I mostly agree, but there was a movement around when I first graduated to get rid of all that "pesky db stuff" and reimplement it all in the app instead. I think we're seeing a swing back in the other direction these days but those people are still around of course

  21. moparisthebest

    MSavoritias (fae,ve), singpolyma: for decades MySQL/mariadb allowed you to define foreign keys but then just ignored them, for one example, I haven't checked how it does it now

  22. moparisthebest

    I believe there are still significant caveats when database clusters are involved, up to and including just can't do it

  23. singpolyma

    moparisthebest: for sure. Bad DBs is a different but related problem I guess

  24. moparisthebest

    It's also a design decision, if you enable them then you have to delete and insert in a very specific order, and be aware what cascading might do etc

  25. moparisthebest

    Right I'm just pointing out many bad DBs exist in the wild and that's likely a big reason you won't see them used in real things

  26. lovetox

    in sqlite you need to enable foreign keys on a per session basis

  27. lovetox

    so the db can either ignore them or will honor them

  28. lovetox

    in Gajim we didnt use foreign keys, and now with the new DB Layout we will use them The cascade on delete is nice

  29. lovetox

    about xml:lang, can i depend on at least one body not having a xml:lang? and that is the xml:lang that is set on the stream?

  30. Zash

    I don't think so

  31. lovetox

    ok i think body is the wrong example

  32. lovetox

    my question is about a element that the server sends

  33. lovetox

    not a user

  34. lovetox


  35. lovetox

    say hats for example, so i request existing hats

  36. lovetox

    how do i chose what to display to the user?

  37. lovetox

    now you will say the lang the user uses, but how can i be sure that that lang code is the same lang code the server uses

  38. lovetox

    in this example server sets lang to en-us

  39. lovetox

    what if my client uses "en"

  40. lovetox

    sounds like a bit complicated process where i need to map multiple language codes and normalize them to something

  41. Zash

    I'd look for recommendations or library support, it shouldn't be a completely uncommon problem right?

  42. Zash

    I would expect web frameworks to have things to select a language based on the Accept-Language header, perhaps some of those are useful or can serve as inspiration?

  43. flow wonders if "en" is even a valid value for xml:lang

  44. Zash

    flow, yes, it is

  45. flow

    xml:lang was complicate wasn't it, there was something like en-us.foobar

  46. flow

    so ideally you have some logic to find the closest matching lang

  47. Zash

    Exact match or longest prefix match maybe?

  48. Zash

    split into tokens, don't pick whatever starts with e

  49. moparisthebest

    Cascade on delete is nice until you don't want it and oops... It's an especially large foot gun for new devs coming in 😁

  50. flow

    looking at https://www.w3.org/International/articles/language-tags/#rfc, the values seems to be easy tokenizable

  51. flow

    so just split by '-' and use the one with the longest prefix matches?

  52. lovetox

    Zash, this is for nbxmpp the Gajim xmpp lib

  53. flow

    actually I think smack has something for that

  54. lovetox

    so i split and take the first token

  55. lovetox

    sounds like a plan

  56. Zash

    so if your preference is cs-CZ you would look for an exact match, then cs-*, then cs, then give up and pick something

  57. jonas’

    RFC 5646 (<https://datatracker.ietf.org/doc/html/rfc5646>) and RFC 4647 (<https://datatracker.ietf.org/doc/html/rfc4647>) are what to look at

  58. jonas’

    you can get quite far without actually doing the RFC 5646 dance and just implementing the algorithm in RFC 4647 on strings

  59. jonas’

    lovetox, I have an implementation in aioxmpp, I'm happy to donate it to gajim under whichever FOSS license you choose

  60. jonas’

    moparisthebest, FWIW, as much as I despise mariadb, it has improved and with InnoDB, you can have clustering and properly enforced constraints, we're running a couple clusters in prod.

  61. jonas’

    (yes, MyISAM was and is terrible, no questions there, but nobody uses that anymore)

  62. jonas’

    also apparently OpenStack isn't a real thing? it uses both mysql and foreign keys a lot

  63. moparisthebest

    Our DBAs have still mandated no FKs in prod, I think because of cluster reasons but I haven't asked in years... We've certainly always been on InnoDB though

  64. lovetox

    thanks, jonas’ will check it out later

  65. lovetox

    jonas’, can you point me to a file, on codeberg i see no search field

  66. lovetox

    i found a LanguageTag class, but it says > This may be a fully RFC5646 compliant implementation some day, but for now it is only very simplistic stub

  67. lovetox

    ah i think i found it, there are some lookup/filter methods

  68. jonas’

    lovetox, exactly

  69. jonas’

    the LanguageTag is just a stub, but the matchers should be RFC 4647 compliant, and that's what you're gonna need

  70. Shinobi


  71. Shinobi

    I credited my acc with some coin but it did not reflect, why?

  72. Zash

    Wrong place