-
-
Notifications
You must be signed in to change notification settings - Fork 521
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
[management] Refactor group to use store methods #2867
Conversation
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
…unt-refactoring # Conflicts: # management/server/sql_store.go
@bcmmbaga When you use ExecuteInTransaction, storeEngine always returns empty value. |
I didn’t quite understand this. Are you getting an empty value when calling |
For example, if you call “s.storeEngine” in this method, it returns an empty value. Because this method is called from a transaction. netbird/management/server/sql_store.go Lines 983 to 993 in 669904c
|
…nt-refactoring # Conflicts: # management/server/sql_store.go
This can cause many problems in the future. When you try to access this value in the methods called by the transaction, it will return empty. |
You're right. However, the Store methods should be generic across all databases and shouldn't include unique implementations for each supported database. Therefore, we shouldn't reference the specific engine in the Store implementation. There's currently a TODO in |
This is needed for MySQL Integration. Because key is a reserved word for MySQL. You cannot use it in queries without enclosing it in double quotes. But when you use it with double quotes, an error occurs because Sqlite and Postgres queries do not support it. In this case, we should check for Mysql and Postgres and use the correct one. https://doc.ispirer.com/sqlways/Output/SQLWays-1-205.html The “queryCondition” value must take the correct value according to the current engine.
|
@ismail0234 In that case, you can pass the store engine to this initialization, allowing the transaction to be aware of the current engine in use netbird/management/server/sql_store.go Lines 1117 to 1121 in d58cf50
func (s *SqlStore) withTx(tx *gorm.DB) Store {
return &SqlStore{
db: tx,
storeEngine: s.storeEngine,
}
} |
Thanks. Will you add this? I am currently querying the database name to overcome this problem.
|
Yes. I’ll add that. |
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
# Conflicts: # management/server/group.go # management/server/group/group.go # management/server/setupkey.go # management/server/sql_store.go # management/server/status/error.go # management/server/store.go
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
# Conflicts: # management/server/account.go # management/server/status/error.go
Signed-off-by: bcmmbaga <[email protected]>
Signed-off-by: bcmmbaga <[email protected]>
# Conflicts: # management/server/group.go
Quality Gate passedIssues Measures |
Describe your changes
Remove calls to get and save whole account in group operations.
Issue ticket number and link
Checklist