Replies: 10 comments 15 replies
-
Are you able to provide the code that you have currently or describe what you'd like to do in more detail (and specifically what issues you're having)? There's not a lot of direct documentation out there for this stuff unfortunately but I can try to unblock you and get something started for that. |
Beta Was this translation helpful? Give feedback.
-
How are you currently running the queries? There seems to be some issues currently it looks like - for example I can get the notifications to fire when I use Do you want this to be a background thing or do you want to actually open up an editor and then run the query in there? And then are the messages something you actually plan on using yourself? |
Beta Was this translation helpful? Give feedback.
-
This is great. For the dispose: do you know if it unsubscribes the callbacks from the register* methods? Or is there anything that does?
At the moment, I'm glomming everything into one statement and hoping for the best:
Re: runQueryAndReturn: I would have expected it to behave that way too, but it doesn't seem to:
Expected: Divide by zero error encountered.
Expected: Invalid object name 'dbo.MyTableWhichDoesNotExist'. |
Beta Was this translation helpful? Give feedback.
-
DisposeQuery does not unsubscribe any callbacks that were registered (those callbacks are a global thing for the provider, not tied to a specific query). There currently isn't a way to unsubscribe to those callbacks either - once you've set one up it will continue to be called until ADS is restarted. Probably behavior we should change but for now you'll just have to ignore the "extra" events that you'll be getting if you use any of them. What you have with registering the callback multiple times isn't what you want - since the first one will also be triggered from any subsequent queries (or any queries being completed at all). Instead you'd want to set up a single callback and then somehow in there determine which of your callback methods you want to call based on the info passed to you (uri and state) That's unfortunate about the error not throwing - I'll see if I can dig into this stuff and find a way to get the behavior you want (or fix it so it behaves correctly). But for now you'll just have to find another way I guess. A real hacky solution would be to have the TRY/CATCH in the query itself, and then return a "special" value if it fails. Then you could just check the return value for that. Probably easier than trying to hook into the messages callback (especially given that runQueryAndReturn doesn't trigger those) |
Beta Was this translation helpful? Give feedback.
-
Re: registering callback1,2,3: that's what I thought, which is why I don't do it. I think the real best way forward, for me, right now, is to:
Re: hacky solution: I'm doing something in essence like that to pass output parameters back to the controller. I'm assuming there's currently no parameterization capabilities that I overlooked. Re: errors not throwing. Please do check my examples, but that's what I get. I'd imagine that there'd be more appetite in creating a new method than changing the operations of an existing one. Do you think it's worth me opening an Issue for discussion, or is the team overloaded right now? If so, I'd be interested in getting that discussion going. |
Beta Was this translation helpful? Give feedback.
-
If you could open an issue that'd be great! I can't promise we'll be able to get to it immediately but getting it out there would let us have all the context in one place and help other people who might try to use that same API. And no, I don't believe we have any support for parameters at this point unfortunately. |
Beta Was this translation helpful? Give feedback.
-
OK, thanks. I'll start up an issue with everything I can think of summarized. |
Beta Was this translation helpful? Give feedback.
-
#19523
Please let me know if I messed anything up. |
Beta Was this translation helpful? Give feedback.
-
I don't think there's much more to add, so I'm marking this as answered. |
Beta Was this translation helpful? Give feedback.
-
Hi, opening this up again because I'm experiencing some problems.
You can see that I'm creating a new connection from the original, then using that connection for the query registration and execution. Here's the accumulateResults:
This webview works fine, but the issue is the side effects. Here's the script:
I've attached a picture of the new query window state. I've also attached a ZIP file of the extension code, though I stripped out the .\nodes folder to make it compact enough. I'm also unmarking the previous answer, since it doesn't seem to be complete. |
Beta Was this translation helpful? Give feedback.
-
Hi all, not sure if this is the best place to ask this, but I don't see much discussion elsewhere.
I'm starting to develop extensions for internal use at my workplace, and can't find any documentation on proper ways of executing SQL. I've only been able to find one Q&A, which references the QueryProvider.runQueryAndReturn method. This doesn't work for me for two reasons:
I've started to play around with runQueryString, and subscribing to notifications via registerOnMessage and registerOnQueryComplete. This isn't nearly as easy as firing sql through runQueryAndReturn and AWAITing the response, but I have made some guesses. However, I'm confused as to where to only subscribe to queries my process is executing, how to unsubscribe, etc. I'm currently seeing some bizarre results when opening up a new query window and simply running SELECT 1 after my process runs.
Documentation and examples would be great if anyone has them.
Beta Was this translation helpful? Give feedback.
All reactions