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
mssqldef: support declare in trigger #137
Conversation
As I was making other changes, I realized that it might be better to leave the formatting of the trigger's body to the generator instead of the I'll make some modifications. |
Out of curiosity, how many features do you plan to add to sqldef after this? Now that you've made significant contributions to sqldef, if you have many more to do, I'm thinking it might be easier for you to sometimes directly push changes to master as a committer instead of making a pull request every time. What do you think? |
Thank you for your concern. My unfinished work on sqldef is to support the following syntax for use in triggers.
The number may fluctuate, but I'm assuming that it will not be too many. |
I modified it so that the generator can control the generation of trigger statements. Currently, it only supports sql server, so it is a redundant process of just calling I would like to ask for advice on which policy is more appropriate, the previous one or the current one. |
OK. But then could you give a short description for each of the previous one and the current one and summarize the pros and cons of each option first, instead of leaving a part of that information in individual comments? It should be actually easier for the author who actually worked on a problem to see challenges in implementing a solution for the problem, so it's still your responsibility to clarify what should be considered. Otherwise, I'd need to re-implement what you did to "see if there are any inappropriate changes". |
Yes, the two implementations are described below. 1. Define the statement of the trigger as
|
Thank you for writing this down. This is really helpful. You said that everything you will add to sqldef from this point is going to be about TRIGGER (please let me know if anything not related to TRIGGER is also missing for your use case). If that's the case, especially because you said it's not too many, could you file all pull requests you'd like to merge to sqldef first? That way, I can confirm your design decision is applicable to those and compatible with them while reviewing it. Note that this is not a request to create a single big pull request. I'd like you to file pull requests as if they were merged one by one. Once you have all changes in your repository, please use this branch as a base of your second pull request, use it as a base for your third, and so on. As you're requesting to get reviews for all of these, I'd like to see a similar kind of summary for those pull requests as well. Thank you in advance. All of your contributions have been much appreciated! |
Thanks for the confirmation! I would like to confirm the following.
I'm thinking of reverting to keeping the trigger statement as a string (757c233) and then deriving a branch, am I right? |
Sounds good. For each pull request, I expect you to leave a version as the last commit that you prefer according to your discussion associated with each pull request. |
This reverts commit 4788e57.
So I'm starting to review your PRs, but I noticed these are not chained but simply share the same diffs. To help my review process, let me re-create PRs with your commits in this repository's branch so that we can compare the diff for each PR. |
re-created the PR as #144 |
I'd like to go with the simple approach as long as we don't hit a use case that is not compatible with the design. Let's try to maintain robustness around https://github.com/k0kubun/sqldef/blob/313678a42f93d5b731c8dc2feee7e663993cce3d/schema/generator.go#L1342-L1343 for now. |
I made a change to allow
DECLARE ...
to be used in the trigger syntax.We can declare variables and cursors within the declare syntax.
Cursor can be used when we want to loop through the result set one record at a time.
This change only supports declarations, so it is just a test to check the parsing, but I can change it to meaningful tests with cursors by supporting
Fetch cursor ...
andOPEN cursor ...
after this.