querymx / querym

Querym is free, open-source and cross-platform MySQL and PostgreSQL GUI client.
https://querym.net/
GNU General Public License v3.0
94 stars 28 forks source link

Remove a row of the query result #20

Closed invisal closed 1 year ago

invisal commented 1 year ago

This will be a bit challenging to implement as there are many components at play here. But let try to understand on how it works. First there are 2 important components to understand.

How to find which row is selected

We don't have row selection feature. We can either use cell selection as row selection or we can implement row selection (https://github.com/invisal/query-master/issues/10).

Decide if row can be deleted

We also need to find a way to decide if the row can be deleted. The row can be deleted if and only if the result contains only one table. Query with INNER JOIN can contains 2 or more tables. It is not possible to remove if there are mixing of more than 1 table. The result must have PRIMARY KEY columns

Record which rows are deleted

QueryResultChangeProvider is just a context that wrap around ResultChangeCollector (https://github.com/invisal/query-master/blob/main/src/libs/ResultChangeCollector.ts). Currently, it only support recording which cell is being changed. We need to add ability to record which rows has been deleted.

Transform changed to plans

When we commit, we will call getSqlPlanFromChange (https://github.com/invisal/query-master/blob/main/src/libs/GenerateSqlFromChanges.ts). This will prepare the plans from changes

Transform plans to SQL

Once we have the plan, we transform the plan into raw SQL using this function. https://github.com/invisal/query-master/blob/main/src/libs/GenerateSqlFromPlan.ts

If everything is correctly implemented, it should work. I believe we need to implement row selection first before we can continue this feature. I will write up how to implement the row selection shortly as well.

ebfood commented 1 year ago

Can you provide more information, such as some details about the interaction? I would like to work on this issue, also #21

invisal commented 1 year ago

@ebfood sorry for late reply. I will write how to achieve it shortly. Been a bit busy lately.

ebfood commented 1 year ago

Thank you so much for your detailed response. Implementing this feature seems to be more complex than I imagined, but fortunately, you have provided a detailed outline of the general approach. I believe that selecting a specific row is quite important for this feature, so perhaps I would like to work on #44 first and then continue with this issue.

invisal commented 1 year ago

@ebfood it is also entirely my fault as well. I didn't have good planning at first. I haven't never worked on developing database GUI client before. So I just implement thing as I goes. There is something that I would slightly do differently if I have chance to start again. But well, the project is still early stage anyway :)

ebfood commented 1 year ago

@invisal You have already done a great job! I have some coding experience with Electron-based editors, and I'll assist you.

invisal commented 1 year ago

Since we have finished the row selection, we can work on the remove feature. I will write even more more detail tomorrow so that it will make thing easier for you when implement.

invisal commented 1 year ago

@ebfood While, I were doing the insert new row, I also close to finish the remove row as well.