-
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
-
MSavoritias (fae,ve)
i know the basics of SQL but i am struggling with the mental model
-
MSavoritias (fae,ve)
also apparently there is an object variant of sql
-
lovetox
google "SQL Join"✎ -
lovetox
search "SQL Join" ✏
-
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
-
MSavoritias (fae,ve)
ah and i see join just filters doesnt deletes. makes sense
-
MSavoritias (fae,ve)
heh thats why ids in group chats are so important
-
MattJ
MSavoritias (fae,ve), another key word you might want to look up is "foreign key"
-
MattJ
Okay, two words ;)
-
MSavoritias (fae,ve)
ah that makes sense with the relational terminology now
-
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
-
MSavoritias (fae,ve)
so i manually join everything? :( ....
-
moparisthebest
No, joins are very useful but unrelated to the foreign key implementation that some dbs give you
-
moparisthebest
By implementation I mean actually declaring foreign keys and doing cascading deletes and such
-
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.
-
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 🤷♂️
-
MSavoritias (fae,ve)
wtf. i would expect nothing less than a db to be functional/atomic completely
-
MSavoritias (fae,ve)
it either works or it doesnt
-
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
-
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
-
moparisthebest
I believe there are still significant caveats when database clusters are involved, up to and including just can't do it
-
singpolyma
moparisthebest: for sure. Bad DBs is a different but related problem I guess
-
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
-
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
-
lovetox
in sqlite you need to enable foreign keys on a per session basis
-
lovetox
so the db can either ignore them or will honor them
-
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
-
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?
-
Zash
I don't think so
-
lovetox
ok i think body is the wrong example
-
lovetox
my question is about a element that the server sends
-
lovetox
not a user
-
lovetox
https://xmpp.org/extensions/xep-0317.html
-
lovetox
say hats for example, so i request existing hats
-
lovetox
how do i chose what to display to the user?
-
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
-
lovetox
in this example server sets lang to en-us
-
lovetox
what if my client uses "en"
-
lovetox
sounds like a bit complicated process where i need to map multiple language codes and normalize them to something
-
Zash
I'd look for recommendations or library support, it shouldn't be a completely uncommon problem right?
-
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?
- flow wonders if "en" is even a valid value for xml:lang
-
Zash
flow, yes, it is
-
flow
xml:lang was complicate wasn't it, there was something like en-us.foobar
-
flow
so ideally you have some logic to find the closest matching lang
-
Zash
Exact match or longest prefix match maybe?
-
Zash
split into tokens, don't pick whatever starts with e
-
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 😁
-
flow
looking at https://www.w3.org/International/articles/language-tags/#rfc, the values seems to be easy tokenizable
-
flow
so just split by '-' and use the one with the longest prefix matches?
-
lovetox
Zash, this is for nbxmpp the Gajim xmpp lib
-
flow
actually I think smack has something for that
-
lovetox
so i split and take the first token
-
lovetox
sounds like a plan
-
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
-
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
-
jonas’
you can get quite far without actually doing the RFC 5646 dance and just implementing the algorithm in RFC 4647 on strings
-
jonas’
lovetox, I have an implementation in aioxmpp, I'm happy to donate it to gajim under whichever FOSS license you choose
-
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.
-
jonas’
(yes, MyISAM was and is terrible, no questions there, but nobody uses that anymore)
-
jonas’
also apparently OpenStack isn't a real thing? it uses both mysql and foreign keys a lot
-
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
-
lovetox
thanks, jonas’ will check it out later
-
lovetox
jonas’, can you point me to a file, on codeberg i see no search field
-
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
-
lovetox
ah i think i found it, there are some lookup/filter methods
-
jonas’
lovetox, exactly
-
jonas’
the LanguageTag is just a stub, but the matchers should be RFC 4647 compliant, and that's what you're gonna need
-
Shinobi
Wasup
-
Shinobi
I credited my acc with some coin but it did not reflect, why?
-
Zash
Wrong place