Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate database-related code from ServerLobby #5124

Merged
merged 2 commits into from
Jul 19, 2024

Conversation

kimden
Copy link
Contributor

@kimden kimden commented Jul 3, 2024

Here, I split the database-related code previously located in ServerLobby implementation into logic part, which stayed in ServerLobby, and database part (forming queries, all types of sqlite3_* functions), which moved to a new DatabaseConnector class. Apart from that, I reused some code previously repeated while making queries of same type and while binding values (by adding two auxiliary structures), and added some doxygen comments.

I felt like making a separate class for that purpose would do better than not making it, as there a few more variables to keep track of than just database handle, and passing database handle to each of many functions would probably be too long in terms of code.

The amount of changes is pretty big, so I suppose that despite I did some testing, it requires even more of it + I could miss something, feel free to ask me anything about it.

Agreement

By creating a pull request in stk-code, you hereby agree to dual-license your contribution as
GNU General Public License version 3 or any later version and
Mozilla Public License version 2 or any later version.

This includes your previous contribution(s) under the same name of contributor.

Keep the above statement in the pull request comment for agreement.

I also attempted to reuse some code that checks if a peer is banned
easySQLQuery was generalized to return output rows if requested,
which allowed to shorten the code for many queries.

The code for binding values to sqlite statement was also repeated
many times. Two auxiliary structures were introduced, so that it's
possible to provide at the same time both those parameters which
require and those which don't require binding, in a single
StringUtils::insertValues() call.
@CodingJellyfish
Copy link
Member

I trust you.

@CodingJellyfish CodingJellyfish merged commit 355d7cd into supertuxkart:master Jul 19, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants