This repository has been archived by the owner on Feb 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 278
[PREVIEW] When loading from the database, initialize everything right in the constructor #3928
Open
MartinBriza
wants to merge
17
commits into
kingfisher/master
Choose a base branch
from
kingfisher/unify-constructors
base: kingfisher/master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TODO: make it build on Windows and macOS
…larations (lib) The commit message feels like a bunch of gibberish but it really is what it says.
I spent 2 days trying to make this work in Windows but due to MSVC bugs, I have to revert to just doing it with strings and defining columns in the constructor as well
Notice how the deleted number count is higher than added now
MartinBriza
force-pushed
the
kingfisher/unify-constructors
branch
from
March 31, 2020 07:26
fcc8663
to
9737ca5
Compare
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📒 Description
This change consists of three main parts:
src/
folder is now reorganized, thesrc/model
andsrc/database
folders were added to contain models and database-related classes, respectively. Also, some helper classes were moved to thesrc/util
folder.guid
field for all tables representingBaseModel
-derived classes.BaseModel
constructor using the newly addedBaseModelQuery
class that contains information about the table structure and SQL query necessary to reconstruct the model.Especially point 3 is interesting in this PR:
BaseModelQuery is now used like this (probably subject to change because of a MSVC bug on Windows):
It's especially worth noticing that the Query instance in
Workspace
is referencing the one inBaseModel
. That is because theid
,uid
,guid
andlocal_id
fields are now loaded in theBaseModel
(to avoid handling them in all models individually).A different important difference to how things are done now is that previously, we created an empty
Workspace
instance and then used setters to modify its properties. Not doing that is beneficial especially in two ways:ProtectedContainer
right when constructing the value (no shifting around after using the setter)SetDirty()
when loading the values from the DB anyway).Having the database model defined inside the class that's represented by it also benefits us by letting us use a single template method to load all data - reduces boilerplate code in the
Database
class that's pretty large now.The constructor now can look like this:
And the universal loading method in
Database
is much simpler (simplified code without error handling, full source is at the end of thedatabase.cc
file):This is now used for Workspace only, to verify everything works right (which it doesn't because it's not possible to compile the code using MSVC).
🕶️ Types of changes
👫 Relationships
Part of the Kingfisher project
🔎 Review hints
This is a preview. Test the functionality and tell me your opinions on the code.