* WIP
* All the new RowCreate tests are working
* Fixing a couple bugs with the row delete and row update tests
* Regenerating localization files
* Fixing multiple iteration in tests
* Support `GO N` syntax to execute multiple times
- Plumbed through the batch execution count from the parser and used in the batch execution code path
- Functionality matches SSMS:
- Outputs loop start/end messages that match SSMS if you're doing multi-batch execution
- Outputs an "ignoring failure" error if an error happens during a batch
- Added tests for this
- Manually verified end to end also
* Fixing test error
* Revert "Add rowcount check so that no results error is sent for a query where no rows are returned (#525)"
This reverts commit 3392f93a2e.
* Revert "Add unknown status for DB Nodes whose status is not known (#524)"
This reverts commit 3d7b87eca2.
* Revert "Should await result of requestcontext.sendresult in case it errors (#520)"
This reverts commit caf196ea31.
* Fix to make sql exceptions surface properly to user (with important notes!)
* Adding support for detecting column size issues when updating a cell
* Adding unit tests for the exception on read scenario
* Avoid crashing if azure edition is System.
* Add new Azure-specific options to the prototype and return through the service calls
* Send azure properties over database info request
* IsCloud should include Azure SQL DW
- Fixed references to this feature flag
- Updated edition handling to include ManagedInstance and removed AzureV1 check since it's never used and it's been retired.
* Fix https://github.com/Microsoft/vscode-mssql/issues/986 and add better server edition naming
- Fixed a number of issues related to the binding queue, specifically the fact that it didn't capture exceptions that occurred on the binding thread. This caused the thread to crash the service.
- The root cause of the error was when you get a connection error during init of the SmoMetadataProvider which threw an exception. Because of this no Binder was created, and the code would null ref later during processing
- Added logic to handle null ref issue and other related code
- Added a unit test for the new error handling path, and supported still returning some value in this case
- Separately, have a fix for an issue where the edition is shown as "SQL Azure" for all Azure connections. Fixing to be "Azure SQL DB" for this case and handle when the database reports as DW or Stretch instead. This maps better to users concept of what the edition should be and avoids returning what is an outdated term.
* Messed up the test - fixing this by returning the expected return object
- Compatibility Level should be a numerical value. In using `enum.ToString()` the result was `Version140` instead of `140`
- Backup date should be sensible if never backed up. Added a simple check that states it was never backed up if the backup date is before 1900.
* Bump SMO to 140.2.5 to pick-up private XEvent binaries
* Pick up SMO binaries from the build lab
* Add ProfilerService class placeholder
* Update SMO nuget package to include DB Scoped XEvents
* Stage changes
* Stage changes
* Update SMO to use RTM dependencies and remove separate SqlScript package
* Stage changes
* Iterate on profiler service
* Fix post-merge break in localization
* More refactoring
* Continue iterating on profiler
* Add test profiler listener
* Address a couple of the code review feedback
* Fix AppVeyor build break
* Use self-cleaning test file
* code refactoring
* Add filebrowser service and tests
* change dataset reference
* Address pr comments
* add more tests
* address pr comments
* address pr comments and added more tests
* minor change
* minor fix
* Fix test break and add dataset result check
* inital request
* refactored query execution failure callback to take exception
* added failure callback to execute and return
* added test for query execute and return
* updated params
* removed dead code
* addressed feedback; added multiple active result set support; updated tests
* addessed feedback and added testing and errors and verification
* change <= to ==
* changed name of trashQ to removedQuery
* Create backup task for execution
* Register backup to task service
* Fix backup task service
* Fix async methods
* Add backup unit test
* Add cancellation token to task service and fix other PR comments
* Add SR and fix other pr comments
* Add comments to methods
* Fixed backup cancel test and casing
* Change sleep time in test
* Port over initial block of create db implementation
* Test case placeholder
* In-progress work
* Stage changes to other machine
* Add database prototype strings
* Stage changes to other machine
* Stage changes
* Hook the database info into capabilities discovery
* Stage changes
* Update SMO to latest from ssms_main
* Various clean-ups
* Update localization files
Update the ScriptingService to expose new scripting JSON-RPC APIs that use the SqlScriptPublishModel for script generation.
The SqlScriptPublishModel is the model behind the SSMS scripting wizard. To enable scripting for CLI tools, we've ported SqlScriptPublishModel to .NET Core. The SqlScriptPublishModel wraps the SMO scripting APIs for .sql script generation.
1) Added three new requests to the ScriptingService: ScriptingRequest, ScriptingListObjectsRequest, ScriptingCancelRequest.
2) Generating scripts are long running operations, so the ScriptingRequest and ScriptingListObjectsRequest kick off a long running scripting task and return immediately.
3) Long running scripting task reports progress and completion, and can be cancelled by a ScriptingCancelRequest request.
4) Bumped the SMO nuget package to 140.17049.0. This new version contains a signed SSMS_Rel build of SMO with the SqlScriptPublishModel.
5) For testing, adding the Northwind database schema
TODO (in later pull requests)
1) Integrate the new ScriptingService APIs with the ConnectionService
2) Integrate with the metadata support recently added
This change adds a couple things
_Multipart Identifier Decoding_
The ability to decode a multipart identifier (with or without escaping) has been added to the SqlScriptFormatter utility class. This code is utilized to split a table name provided to the edit/initialize request into schema and table name.
_Default Schema Workaround_
The code that retrieves the SMO metadata objects originally used the `[]` operator to access the objects. Due to a bug(?) in SMO, this results in problems when loading tables without a default schema (in our case if you're logged in as SA). Using the metadata object constructors gets around this issue, we are explicitly using them.
* Adding decoding of multipart identifiers
Adding code fix for default schema issue
* Adding some more localizable strings for errors when loading metadata
* Adding localization files... again?
* Changes as per pull request comments
* Ensures that metadata is "extended" before creating a new row edit object
* Adds the commit handler to edit data service initialization calls
* Unit tests for the associated changes
* Major refactor of EditDataMetadata providers
* EditMetadataFactory generates "basic" EditTableMetadata objects based entirely on SMO metadata
* SmoEditTableMetadata no longer depends on SMO, making it unecessary to mock it
* Renamed SmoEditTableMetadata to EditTableMetadata
* EditTableMetadata can be extended with DbColumnWrappers
* Moving logic for extending a EditColumnMetadata into that class
* I *think* this will work for async execution of initialize tasks
* Fixing unit tests for new Edit(Table|Column)Metadata classes
* Async stuff that works! And passes unit tests
* Adding unit tests
Adding .idea to gitignore
* Adding message to the EditSessionReadyEvent
* Fixes from dev merge
* Fixing unit tests that Rider didn't catch as failing
May have been a bit heavy-handed with the async/await stuff
* Couple changes as per PR comments
Very small feature add to make sure that values entered for `TIME` columns are < 24hrs. If the value is >=24hrs when setting the column, an exception will be thrown that the edit/updateCell handler will catch and convert into an error on the JSON RPC side.
* Adding validation of timespan columns
* Fixing a merge conflict
// edit/dispose -------------------------------------------------------------------------------
export interface EditDisposeParams extends IEditSessionOperationParams { }
export interface EditDisposeResult { }
* Initial plumbing for edit/revertCell
* Implementation of revert cell in the parents of the row edit base
* Adding unit tests
Returns strings for the default value of a column when a new row is created. The values that could come back:
* `null` when there isn't a default for the column
* a string when there is a default for the column
* a placeholder (currently <TBD>) when the column cannot be updated
* Renaming EditTableMetadata to reflect its SMO source
* Implementation of returning default values
* Unit test for default values
* Reworking column defaults using default constraints
* Adding unit test for new sql script unwrapper
* Disabling flaky test
* Fixing oddities in tests, removing personal tests
* Fixing broken unit test
The main goal of this feature is to enable a command that will
1) Generate a parameterized command for each edit that is in the session
2) Execute that command against the server
3) Update the cached results of the table/view that's being edited with the committed changes (including computed/identity columns)
There's some secret sauce in here where I cheated around worrying about gaps in the updated results. This was accomplished by implementing an IComparable for row edit objects that ensures deletes are the *last* actions to occur and that they occur from the bottom of the list up (highest row ID to lowest). Thus, all other actions that are dependent on the row ID are performed first, then the largest row ID is deleted, then next largest, etc. Nevertheless, by the end of a commit the associated ResultSet is still the source of truth. It is expected that the results grid will need updating once changes are committed.
Also worth noting, although this pull request supports a "many edits, one commit" approach, it will work just fine for a "one edit, one commit" approach.
* WIP
* Adding basic commit support. Deletions work!
* Nailing down the commit logic, insert commits work!
* Updates work!
* Fixing bug in DbColumnWrapper IsReadOnly setting
* Comments
* ResultSet unit tests, fixing issue with seeking in mock writers
* Unit tests for RowCreate commands
* Unit tests for RowDelete
* RowUpdate unit tests
* Session and edit base tests
* Fixing broken unit tests
* Moving constants to constants file
* Addressing code review feedback
* Fixes from merge issues, string consts
* Removing ad-hoc code
* fixing as per @abist requests
* Fixing a couple more issues
* Initial credential service files
* Clean-up hostloader
* Update build scripts to build credentials archive
* Move hosting files to new assembly
* Add credentials files to MS.SqlTools.Credentials
* Remove duplicate files
* Update namespace in program.cs
* Fix test build breaks
* Update extensions visibility.
* Remove unused resource strings
* Add xproj files to SLN for appveyor builds
* Fix appveyor build break in test project
* Fix extensibility tests
* Fix various typos in latest iteration
* Add settings for Integration build
* Fix codecoverage.bat to use full pdb for new projects
* Fix bug when packing in folder with native images
* Fix typos in xproj
* Reset XLF to fix build.cmd
This is a very large change. I'll try to outline what's going on.
1. This adds the **EditDataService** which manages editing **Sessions**.
1. Each session has a **ResultSet** (from the QueryExecutionService) which has the rows of the table and basic metadata about the columns
2. Each session also has an **IEditTableMetadata** implementation which is derived from SMO metadata which provides more in-depth and trustworthy data about the table than SqlClient alone can.
3. Each session holds a list of **RowEditBase** abstract class implementations
1. **RowUpdate** - Update cells in a row (generates `UPDATE` statement)
2. **RowDelete** - Delete an entire row (generates `DELETE` statement)
3. **RowCreate** - Add a new row (generates `INSERT INTO` statement)
4. Row edits have a collection of **CellUpdates** that hold updates for individual cells (except for RowDelete)
1. Cell updates are generated from text
5. RowEditBase offers some baseline functionality
1. Generation of `WHERE` clauses (which can be parameterized)
2. Validation of whether a column can be updated
2. New API Actions
1. edit/initialize - Queries for the contents of a table/view, builds SMO metadata, sets up a session
2. edit/createRow - Adds a new RowCreate to the Session
3. edit/deleteRow - Adds a new RowDelete to the Session
4. edit/updateCell - Adds a CellUpdate to a RowCreate or RowUpdate in the Session
5. edit/revertRow - Removes a RowCreate, RowDelete, or RowUpdate from the Session
6. edit/script - Generates a script for the changes in the Session and stores to disk
7. edit/dispose - Removes a Session and releases the query
3. Smaller updates (unit test mock improvements, tweaks to query execution service)
**There are more updates planned -- this is just to get eyeballs on the main body of code**
* Initial stubs for edit data service
* Stubbing out update management code
* Adding rudimentary dispose request
* More stubbing out of update row code
* Adding complete edit command contracts, stubbing out request handlers
* Adding basic implementation of get script
* More in progress work to implement base of row edits
* More in progress work to implement base of row edits
* Adding string => object conversion logic and various cleanup
* Adding a formatter for using values in scripts
* Splitting IMessageSender into IEventSender and IRequestSender
* Adding inter-service method for executing queries
* Adding inter-service method for disposing of a query
* Changing edit contract to include the object to edit
* Fully fleshing out edit session initialization
* Generation of delete scripts is working
* Adding scripter for update statements
* Adding scripting functionality for INSERT statements
* Insert, Update, and Delete all working with SMO metadata
* Polishing for SqlScriptFormatter
* Unit tests and reworked byte[] conversion
* Replacing the awful and inflexible Dictionary<string, string>[][] with a much better test data set class
* Fixing syntax error in generated UPDATE statements
* Adding unit tests for RowCreate
* Adding tests for the row edit base class
* Adding row delete tests
* Adding RowUpdate tests, validation for number of key columns
* Adding tests for the unit class
* Adding get script tests for the session
* Service integration tests, except initialization tests
* Service integration tests, except initialization tests
* Adding messages to sr.strings
* Adding messages to sr.strings
* Fixing broken unit tests
* Adding factory pattern for SMO metadata provider
* Copyright and other comments
* Addressing first round of comments
* Refactoring EditDataService to have a single method for handling
session-dependent operations
* Refactoring Edit Data contracts to inherit from a Session and Row
operation params base class
* Copyright additions
* Small tweak to strings
* Updated unit tests to test the refactors
* More revisions as per pull request comments
Fixes a bug where the GetOrOpenConnection method of the ConnectionService would throw if the connection didn't exist. It would yield a very unhelpful "key not found in collection" exception. The code has been updated to be much more helpful and fix the bug.