-
Notifications
You must be signed in to change notification settings - Fork 32
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
add reset function to db backend #62
base: master
Are you sure you want to change the base?
Conversation
#define sql_autoincrement_string "" | ||
#define sql_autoincrement_string " " | ||
#define sql_last_insert_id_string " SELECT last_insert_rowid() " | ||
#define sql_get_table_names "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%s_%%'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file has conflicts, please fix them.
include/core/jbackend-operation.h
Outdated
@@ -108,10 +108,29 @@ gboolean j_backend_operation_unwrap_db_update (JBackend*, gpointer, JBackendOper | |||
gboolean j_backend_operation_unwrap_db_delete (JBackend*, gpointer, JBackendOperation*); | |||
gboolean j_backend_operation_unwrap_db_query (JBackend*, gpointer, JBackendOperation*); | |||
|
|||
gboolean j_backend_operation_unwrap_reset(JBackend* backend,gpointer,JBackendOperation*); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be j_backend_operation_unwrap_db_reset
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the intention was to have one reset function for all backend types
include/core/jbackend-operation.h
Outdated
gboolean j_backend_operation_to_message (JMessage* message, JBackendOperationParam* data, guint len); | ||
gboolean j_backend_operation_from_message (JMessage* message, JBackendOperationParam* data, guint len); | ||
gboolean j_backend_operation_from_message_static (JMessage* message, JBackendOperationParam* data, guint len); | ||
|
||
static const JBackendOperation j_backend_operation_reset = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question about naming. The structs should also be in the same order as the functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the intention was to have one reset function for all backend types
@@ -429,6 +436,7 @@ gboolean j_backend_db_delete (JBackend*, gpointer, gchar const*, bson_t const*, | |||
gboolean j_backend_db_query (JBackend*, gpointer, gchar const*, bson_t const*, gpointer*, GError**); | |||
gboolean j_backend_db_iterate (JBackend*, gpointer, bson_t*, GError**); | |||
|
|||
gboolean j_backend_reset (JBackend* backend, gpointer, GError**); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above for naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the intention was to have one reset function for all backend types
/** | ||
* delete everything in the backend | ||
* \param[in] which namespace to delete | ||
* \param[out] how many "things" are deleted within the specified namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no in and out parameters in the actual function below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gpointer is an input parameter containing a batch structure, Error is a out parameter, where the error message-string may contain the number of elements which are deleted
@@ -53,7 +53,8 @@ enum JMessageType | |||
J_MESSAGE_DB_INSERT, | |||
J_MESSAGE_DB_UPDATE, | |||
J_MESSAGE_DB_DELETE, | |||
J_MESSAGE_DB_QUERY | |||
J_MESSAGE_DB_QUERY, | |||
J_MESSAGE_RESET |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J_MESSAGE_DB_RESET
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the intention was to have one reset function for all backend types - that is why there is no DB prefix
* \param[in] which namespace to delete | ||
* \param[out] how many "things" are deleted within the specified namespace | ||
*/ | ||
gboolean (*backend_reset)(gpointer, GError**); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not inside one of the unions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the intention was to have one reset function for all backend types
@@ -113,6 +113,8 @@ gboolean j_db_internal_delete (gchar const* namespace, gchar const* name, bson_t | |||
gboolean j_db_internal_query (gchar const* namespace, gchar const* name, bson_t const* selector, gpointer* iterator, JBatch* batch, GError** error); | |||
gboolean j_db_internal_iterate (gpointer iterator, bson_t* metadata, GError** error); | |||
|
|||
gboolean j_internal_reset (gchar const* namespace, JBatch* batch, GError** error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
j_db_internal_reset
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the intention was to have one reset function for all backend types - maybe this should be moved somewhere in the core if it should be available for all backend types
the reset function counts all entries in all tables, and then deletes every table within the specified namespace.
this is for unit tests which require a clean backend.
after the test this function can be used to verify, that there are only empty schemata