MySQL Support & Data classes serialisations - #8872
Conversation
- Removed SQLibrary soft dependency - Implemented Jdbc in order to handle mysql - Currently saves serializable data classes FURTHER TESTING IS REQUIRED Next steps is to allow saving unserializable data classes on both SQL and CSV
- Colors, vectors, locations etc... are now save-able - Slight tweaks to the database schema - Fixed config.sk's database table field being completely ignored - More testing was done, confirmed suspicions and fixes applied - Some progress on inventory saving for sql Future plans prior to releasing this: - Saving inventories - Making unserializable data classes save in CSV (hopefully) - Polishing, refining and possible better reimplementation of this (probably wont)
🔍 Triage ChecklistType
Project
|
|
great that you are interested :)
|
|
I had a small conversation regarding inventories with some members of the team on Skript's discord, safe to say i will not be working on inventories for the time being. Yes the current architecture is not perfect, its just a placeholder rn used to make sure the result is achievable, the pull request was made to let others know that i am indeed working on this. Documentation and comments will be added in due time. The implementation is basic, all depends on how the user configures it, the config allows for the use of various tables so the same hosted database could be used by multiple servers I have not seen skNetwork. |
- Gave up and removed Inventory related efforts - Fixed yggdrasil superclass lookup issue, which caused some classes to not be serializable, most notibaly colors & some particles - Deleted most of the prior implemented function thus sql operations use the already implemented serializers - Removed the "short_value" field from the database and changed ordering - Added a serializer for rgb & skript colors so no warning pops up when trying to save a color - Cleared up some bloat - Added architecture documentation
|
Ok so i believe im done, i stepped back a bit and ended up only making mysql support & fixing a yggdrasil issue so now colors and probably(?) some other classes are also serialisable and saved in both csv & sql |
|
Were the previous MySQL implementations actually shipped? I don't necessarily think it's important to support variables saved by the old SQLibrary format since it hasn't been supported in years. I assume you marked AI assistance as |
|
I didnt use AI when creating the pull request, i did for the documentation (i got lazy) and i dont think i can change the original message And im sorry, what are you referring to with "old mysql implementation" as i could think of 3 things rn |
|
Missformed sentence, i meant to say "i didnt use ai PRIOR to creating the pull request" |
Okay :) Re.: MySQL, for practical purposes all three of them. We don't need migrations for database schemas that have only ever been used by you while making this pull request, and we also don't need migrations for the old SQLStorage schema that currently exists in mainline Skript either. This is because no Skript users actually have data with these schemas; you already migrated your own database, and Skript's old MySQL schema hasn't been supported since SQLibrary 7.1 broke in Spigot 1.17. Ideally, the javadocs for each class would contain extensive documentation about the purpose of that class and how it relates to the SQL storage system as a whole; it doesn't need to document every implementation detail, but it should be written so that a person who is reading the code gets an idea of the purpose of that class and—after reading enough javadocs—understands the SQL storage altogether. English is excellent, and it's okay to use AI to fix spelling mistakes and grammatical errors :) I recommend you write the content yourself though, as AI is very bad at writing prudent javadocs and often includes unnecessary detail about what had been wrong previously and omits crucial information about the design. |
I will get these done then get back to you |
- Removed accidentally left-in code that helped me with testing, and migration - Revisited & rewritten the architecture documentation
The SQL implementation uses Skript’s existing serialization system. Skript turns each variable into a name, type, and bytes before passing it to the backend. SQL doesn’t need to know how types work. The MySQL backend saves changes in batches on a background thread. Before writing a batch, it records the pending changes in a recovery file, named mysql-pending.bin. If the database becomes unavailable for whatever reason, those changes can be retried. It also attempts to flush pending changes during shutdown. The same file handles deletions of variables periodically. For colors, the main problem was that 'Color' covers two different representations: 'SkriptColor' and 'ColorRGB' which are different classes (enum & object). I registered them separately so Skript uses the correct serialization format for each. Named colors still go through Yggdrasil’s built-in enum handling, and ColorRGB stores its RGBA value. I also fixed a separate bug in Yggdrasil’s superclass lookup: it was checking the map entry’s class instead of the registered class. The color registrations fixes the enum/object mismatch, the lookup correction fixes superclass resolution generally. These changes apply to shared serialization, so they benefit both CSV and SQL. I hope this is what you wanted :> Also, i will be reworking the whole yggdrasil & colors handling in either a separate PR or continue working on this one, depending on the feedback for this, as sovde requested |
Problem
I saw this on discord with months of no attempts, so i took it upon myself because why not?
As for the serialisation part, its annoying to deal with
Solution
Removing the no-longer-functional SQLibrary soft-dependency and implementing an option from within
Testing Completed
just typical save & broadcast
Confirmed working: int, floats, strings, chars, items, itemstacks, locations, worlds, vectors, particles, bukkit colors, arrays/lists.
Supporting Information
!! Using this optional feature will generate a bin file used for storing pending variable saves that will be accessed on sudden server stops (thus, saving variables that may or may not have already been saved)
Most of the work is on sql, inventories are still not supported but im working on them.
Planning to make unserializable datatypes work on CSV too in due time.
Completes: this should be revised prior to any confirmation and merging.
Related: i dont think anything?
AI assistance: none
THIS IS NOT COMPLETE YET