Commit Graph

510 Commits

Author SHA1 Message Date
Leila Lali
88eb0f699b fixed build issues (#315)
* fixed build issues
2017-04-14 11:47:25 -07:00
Aditya Bist
6daadcf8cc Bug/fix peek definition integration test (#313)
* removed race condition in peek definition test

* temporarily disabled peek definition tests

* fixed peek definition connection race condition
2017-04-13 16:03:44 -07:00
Leila Lali
a1bc1bc344 fixed the issue with loading dlls for service provider (#312)
* fixed the issue with loading dlls for service provider
2017-04-13 15:57:56 -07:00
Leila Lali
d903ba56a9 Object Explorer Service (#311)
* moving OE service from an old branch
2017-04-11 15:50:20 -07:00
Raymond Martin
90861b7d9e Localization updates (#310)
* adding template files

* adding templates to build.cake

* removing files we don't need

* fixing whitespace
2017-04-07 15:05:49 -07:00
Karl Burtram
06c106b18a Show systables for master db (#309) 2017-04-06 19:25:23 +00:00
Kevin Cunnane
f3bf330da6 Connect with different properties should actually change context (#307)
* Connect with different properties should actually change context
- Up to now, calling Connect for a previously-connected URI would disconnect, then reconnect ot the original (not new) target. WIth these changes we handle changes to database name or other key properties by updating the ConnectionInfo and connecting to the new target
- Some interesting scenarios are raised by our API, notably that an empty database name maps to the default DB (which we know nothing about). This limits the new feature such that only if the DB Name is specified, we'll change the connection. Hence 2 calls to an empty DB will not result in a DB change.

Additional changes:
- After discussion with Ben, we're simplifying the cancellation logic. He had made changes to support this, so the main update is that we dispose the token in the final block after its last use (hence avoiding a disposed exception) and clean up the number of Waits required since we already have async cancellation support
- Factored some logic such that the OnConnection callback isn't invoked until after we've updated the database name in the GetConnectionCompleteParams method. Again, this supports reporting the actual DB name instead of leaving it blank for default DB requests.

* PR comment fixes
2017-04-06 11:25:59 -07:00
Aditya Bist
1a384d93b4 Bug/fix peek definition integration test (#306)
* removed race condition in peek definition test

* temporarily disabled peek definition tests
2017-04-05 16:03:58 -07:00
Raymond Martin
ea5b151dcd Removing unused constants (#299)
* removing unused constants

* updating test strings

* adding edit data string

* fixing tests
2017-04-05 15:49:44 -07:00
Benjamin Russell
2eb60f45c9 Send Error Object on SendError (#304)
This change ensures that when calling `requestContext.SendError` you are only able to supply parameters that match the language service beta protocol expected Error object. In other words, you have to provide an error message and optionally and error code.

# **BREAKING API CHANGES**
This will break displaying errors in Microsoft/vscode-mssql. I will be making changes to properly handle the error object shortly.

* Adding contract for returning Error objects as per LanguageService "protocol"

* Fixes throughout codebase to send only error message in error cases
Cleanup of CredentialServiceTest unit test class
Adding standard error handling for event flow validator

* Adding optional data field as per protocol spec
https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md

* Adding optional validation for error objects
2017-04-05 14:47:37 -07:00
Aditya Bist
f9138b27df removed race condition in peek definition test (#305) 2017-04-04 17:57:37 -07:00
Benjamin Russell
d9399d05f5 Removing potential for sensitive data to be in debug logs. (#303)
Small change that removes logging complete JSON objects that are sent back from the tools service via JSON RPC. Now the message type and method is logged only. In previous releases, if debug logging was enabled, all JSON objects sent from the tools service would be logged in the debug log, if enabled. This was bad for 2 reasons:
1) sensitive data (passwords from credential service, cell contents) would be logged
2) the log would quickly become massive due to all rows being written to the log, every time they were requested.
2017-04-03 13:48:39 -07:00
Benjamin Russell
e548ae67b5 Adding EditCell constructor validation (#301)
* New unit tests!
* New CopyTo method!
* New null validation!

YEAH!!!
2017-04-03 13:20:04 -07:00
Benjamin Russell
65456ae35b Returning EditCell in EditRows (#302)
Instead of returning DbCellValues inside an EditRow, we should be returning EditCells. This way we can preserve dirty state when scrolling.
2017-04-03 13:12:53 -07:00
Benjamin Russell
ae178efe3e Fixing misc edit bugs (async/await, table not found) (#300)
* Async/await issue when requesting a edit/subset
* Returning good error messages when table/view doesn't exist
2017-03-31 13:59:44 -07:00
Benjamin Russell
42498446cc Implicit Revert Row Cleanup Logic (#297)
This change enhances the way that edit/updateCell and edit/revertCell operations are performed. 

## **THE API BREAKING CHANGES**:
* edit/updateCell now returns an EditCell (a DbCellValue with a dirty flag) and a row dirty flag.
* edit/revertCell now returns an EditCell (a DbCellValue with a dirty flag) and a row dirty flag.

If by setting the value of a cell via edit/updateCell the row no longer has any edits (an "implicit revert"), the entire row's edit will be removed from the cache. Additionally, if by requesting edit/revert all the pending edits for a row are removed, the entire row's edit will be removed from the cache. This will prevent issues where committing will generate an invalid script because it has no pending changes.

* Adding EditCell class
Returning EditCell with EditUpdateCellResult

* Adding code that will remove a row update if the row is clean after a cell update

* Adding code that will return an EditCell and row dirty flag when a cell is reverted.
If the row is reverted by the cell revert, the pending update will be removed

* Comments for edit cell

* Changes as per pull request comments
2017-03-29 13:51:29 -07:00
Raymond Martin
fc04f6822f Fix edit data isMemoryOptimized issue (#298)
* adding refresh

* adding a comment

* spelling
2017-03-28 18:35:41 -07:00
Karl Burtram
a1aa3f8b4c Add table and view metadata messges (#296)
* Add SMO table property lookup event

* Fix a couple bugs in column metadata

* Add GetView metadata message
2017-03-28 16:30:46 +00:00
Benjamin Russell
f7036f3f73 Adding decoding of multipart identifiers, default schema workaround (#295)
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
2017-03-27 17:14:21 -07:00
Benjamin Russell
1909310a92 Important bug fixes for edit/commit (extended property check) (#294)
* 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
2017-03-24 15:11:27 -07:00
Leila Lali
d81fa347e5 fixed an issue with setting a boolean option to string (#291)
* fixed an issue with setting an option which Boolean to string
2017-03-24 10:16:55 -07:00
Benjamin Russell
2893276440 Adding back code to send EditInitializeResult, whoops (#293) 2017-03-23 16:33:39 -07:00
Aditya Bist
9e8e1df95e fixed peek definition tokenizing (#281)
* fixed peek definition tokenizing

* fixed signature help test

* added new heuristic for PeekDefinition behaviour

* added tests for new heuristic

* fixed code according to Kevin's CR

* fixed failing test due to shared connection

* changed uri for procedure test
2017-03-23 13:19:59 -07:00
Benjamin Russell
d2fd8f8f41 Ensuring DisplayValue is set to a value when null (#292)
* Ensuring DisplayValue is set to a value when null

* Changes that *actually do something!*

* Changes that *actually do something!*
2017-03-23 11:50:41 -07:00
Benjamin Russell
991421c6f8 Support TOP n When Initializing Edit Sessions (#290)
* Start of edit initialize filtering

* Implementation to utilize filtering

* Unit tests for the refactoring

* Unit tests for query construction
2017-03-22 17:32:41 -07:00
Karl Burtram
f8afee2e94 Make database a non-required option (#289) 2017-03-22 17:02:01 -07:00
Benjamin Russell
16b3874f28 Remove SELECT * from edit/initialize Query (#288)
* 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
2017-03-22 10:53:24 -07:00
Benjamin Russell
d7ecfb1a87 feature/edit/subset (#283)
* Changing query/subset API to only use Result on success, Error on error

* Creating an interservice API for getting query result subsets

* Updates to subset API

* RowStartIndex is now long
* Output of query/subset is a 2D array of DbCellValue
* Adding LongSkip method to LongList to allow skipping ahead by longs
* Moving LongList back to ServiceLayer utilities. Move refactoring

* Stubbing out request for edit/subset

* Initial implementation of getting edit rows

* Unit tests for RowEdit and RowDelete .GetEditRow

* Fixing major bugs in LongList implementation, adding much more thorough tests

* Adding some more unit tests and fixes to make unit tests pass

* Fixing comment
2017-03-21 15:14:04 -07:00
Leila Lali
9e576dea92 Added options to connection parameter (#285)
* Added options to connection parameter
2017-03-21 13:22:29 -07:00
Karl Burtram
addad29b7c Add Scripter class and use it in the ScriptingService (#286)
* Initial scripting commit

* Fix the script CREATE integration test

* Use language service binding queue for scripting

* Update scripting service to have methods for each operation

* Add scripter class

* Fix build break.

* Fix a few bugs

* Use scripter class instead of PeekDefinition class.

* Fix scripting test break

* Fix header incorrectly saying file is generated.

* Add localization tests to address a large block of code not covered by automation.

* Moving system usings to top of using list
2017-03-21 13:18:52 -07:00
Karl Burtram
1150a19eae Update cake to use JSON.Net 9.0.1 to fix build break (#287) 2017-03-21 13:01:36 -07:00
Kevin Cunnane
844358a19c Bump SMO to SSMS 17.0 RC3 bits (#284)
* Bump SMO bits to align with 17.0 RC3 release

* Add updated SMO binary

* Fix formatter failures caused by SqlProc breaking changes
- Changes to SqlProcedureDefinition subclasses mean that the definition starts at "Create Procedure" instead of after it. This highlighted an issue where the prefix region handling was via comma separated list (which adds newlines to the prefix region) instead of newline separated list (which does not).
- Changed the structure to use the 2 different formatters for relevant regions, and verified all tests now pass.
- Also removed unnnecessary Export clause from the SqlTableDefinitionFormatter, since this was spotted during debugging

* Fix sample project.json dependencies
- Fix up the dependencies in our samples as this was failing the build on TravisCI. Should consider in the future whether or not we want to exclude these from CI runs, but for now the benefit is that we're forced to keep the samples up to date.
2017-03-20 14:23:00 -07:00
Wujun Zhou
8d47d5c7b3 Save As Excel (#279)
* Fix dispose pattern usage in SaveAsWriterBase

* Add SaveAsExcel feature

This adds the save as excel function to the backend. To reduce large dependency and run on dotnet core now, this implementation use a raw excel writer (the SaveAsExcelFileStreamWriterHelper.cs) instrad of popular excel library, such as EPPlus or OpenXmlSdk.

* Fix can not open the generated excel file in google sheet

For the file name inside excel, google uses a case sensitive path while
Excel doesn't. This change fix the case, so that the file name matches
the one in x1/_rels/workbook.xml.rels

* Fix datetime doesn't recognized by google sheet

Google doesn't support cell type t="d" with ISO 8601 date. (From stackoverflow thread and testing), thus use the old way of excel datetime, which uses double to present datetime

* update to use xmlwriter

* Add basic unit tests for SaveAsExcelFileStreamWriterHelper

* refactor: simplify the public interface of the SaveAsExcelFileStreamWriterHelper

* update private fields names based on the name convention

* Add comments to classes of SaveAsExcel feature

* clean up SaveAsExcelFileStreamWriterHelper

- change SaveAsExcelFileStreamWriterHelper from public to internal
- remove the PenddingRowEndTag function from referenceManager
- change the SaveAsExcelFileStreamWriterHelper(stream) to default leaveOpen to false to match the normal behavior
- change the rowreference to use XmlConvert to convert int to string
- rename writeSetting to writerSetting and add private

* fix CI test error for SaveAsExcel

* remove ExporterException in SaveAsExcel

* fix lefe over CSV to Excel in the comments

* refactor to be consistent with JsonWriter and remove the comment

* remove commented out test

The test is too slow to run

* fix typo in comment

* refactor SaveAsExcel to the coding standard

* refactor rewrite the WriteStyle with XmlWriter

* Add licence header

* reverse mistakenly checked-in changes

* fix: left-over CSV in commets

* remove duplicate check

The check was done in the IncreaseColumnReference, but that check is too late in case of too many columns. All the addCell do the check at the begining now

* fix TimeSpan more than 24 hours

* fix AddRowMustBeCalledBeforeAddCellException test

This is  due to remove duplicate call to AssureColumnReference in  WriteAndIncreaseColumnReference

* fix: TimeSpan will write twice

* style: change retun in the switch to break

* Add bool format

* remove todo in comment

This provides extra safeguard in the cost of one memory access when null.
2017-03-16 14:33:12 -07:00
Kevin Cunnane
8d017368f9 Fixes #721 (#282)
- Ensure minimum of 2 newlines after GO statement
- All existing unit tests are passing, indicating this is respecting scenarios where users have comment lines after GO statements (this happens in many other tests)
2017-03-16 10:20:22 -07:00
Karl Burtram
7ba2011a1e Initial metadata and scripting services (#280)
* Initial metadata service and scripting service files

* Simple metadata lookup with SMO objects

* Add metadata type class

* Remove SMO from metadata service.

* Cleanup metadata service SQL

* Initial MetadataService test

* Add scripting commands

* Add metadata test case

* Remove sleep used for testing

* Use random table name in metadata test

* Add scripting tests
2017-03-14 22:35:17 -07:00
Brian O'Neill
9b1e07907e Add nuget package SqlScriptPublishModel. (#277)
The SqlScriptPublishModel is the model behind the SSMS scripting wizard. It has been ported to .NET Core to enable scripting scenarios to SqlToolsService. This change adds the SqlScriptPublishModel nuget package to the checked in packages in the bin\nuget folder.
2017-03-13 13:08:27 -07:00
Benjamin Russell
471e64fb1c Adding validation of timespan columns w/in 24hrs (#275)
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
2017-03-10 13:46:13 -08:00
Aditya Bist
125fe8b0e7 removed mono dependency (#276) 2017-03-09 18:02:42 -08:00
Benjamin Russell
f2afa07a93 NULL column validation when updating cells (#274)
* Adding validation that NULL is allowed when setting cell values

* Adding unit tests
2017-03-09 16:14:25 -08:00
Karl Burtram
8f3e83b519 Add nvarchar to IntelliSense keyword list (#272) 2017-03-09 14:33:43 -08:00
Karl Burtram
41a2564921 Add GroupName property to ConnectionOptions (#273) 2017-03-08 18:20:43 -08:00
Benjamin Russell
c0468e763f edit/revertCell (#268)
// 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
2017-03-08 14:49:13 -08:00
Karl Burtram
666ee98582 Add description field to ConnectionOption object (#271) 2017-03-08 14:09:12 -08:00
Benjamin Russell
056a08cd1b edit/createRow Default Values (#266)
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
2017-03-08 13:51:38 -08:00
Benjamin Russell
29d27c2341 Block Initializing Edit Sessions When In Progress (#265)
* Implementation of a wait handle for initialize

* WIP

* Adding more initialize unit tests
2017-03-07 12:27:48 -08:00
Karl Burtram
17d2d825eb Provide connection options to host process (#267)
* Stage changes to other machine

* Add connection options in init message

* Fix option type
2017-03-07 11:00:52 -08:00
Kevin Cunnane
4de152847e Merge pull request #270 from Microsoft/merge/master
Merge master release 0.3.0 into Dev
2017-03-06 22:33:14 -08:00
Kevin Cunnane
adcc5c8089 Merge latest Dev and latest master 2017-03-06 17:59:41 -08:00
Kevin Cunnane
0f706f28ee Merge from Master 2017-03-06 17:56:04 -08:00
Benjamin Russell
ef3100de3b Changing test projects to UnitTests, fixing peek definition codegen bug (#269) 2017-03-06 17:55:48 -08:00