Commit Graph

23 Commits

Author SHA1 Message Date
Charles Gagnon
dc006be73e Make publish to docker settings properties required (#19898)
* Make publish to docker settings properties required

* move
2022-06-30 16:21:53 -07:00
Charles Gagnon
87f8f2fd90 Additional SQL Proj cleanup (#19836) 2022-06-27 17:29:49 -07:00
Charles Gagnon
5b95a47ca6 Add launchPublishToDockerContainerQuickpick to extension API (#19834)
* Initial

* remove namespace

* minor fixes
2022-06-27 15:29:43 -07:00
Charles Gagnon
887d218342 Add default name to promptAddItem (#19439)
* Add default name to promptAddItem

* Change to addItemPrompt
2022-05-19 15:10:34 -07:00
Charles Gagnon
f2b623b3b2 Move promptAddItem to extension API (#19423)
* Move addItem to extension API

* add noneDeployScripts
2022-05-19 11:25:10 -07:00
Barbara Valdez
132d22bfe7 add open api project method to api (#19401) 2022-05-17 15:09:16 -07:00
Barbara Valdez
742232ddd5 Add option to create sdk style project (#19290)
* update sql proj api

* remove extra spaces

* simplify check
2022-05-04 15:21:13 -07:00
Kim Santiago
bf82204453 add sdk-style option to exposed sql project apis (#19143) 2022-04-19 17:28:27 -07:00
Alexander Ivanov
0f598dd30b Add sqlproj property to trace the origin of the project. (#18670)
* Add sqlproj property to trace the origin of the project.

As part of the database migration process (schema conversion, in particular) we want to be able to tell when converted schemas are being built/deployed to the actual database server. Given that we rely on the SQL Database Projects ADS extension for the compilation/deployment, we don't have too many options other than updating the said extension.

The suggested approach is to make the following changes:
1) Add new property to the sqlproj file (called `DatabaseSource`), which will maintain the origin(s) of the project. The property can contain multiple values (separated by semicolon), in case same project contains objects produced by multiple sources (extract schema, convert from another database, etc.).
2) During build and deploy actions, send the well-known values from the newly added property to the telemetry. We don't want to send any random value of the property, as it may raise some privacy concerns. Instead we define a list of the well-known values that we know do not carry any personal information and send those, if they are specified.

This change adds all necessary APIs to the SQl Database projects extension which will be consumed by our migration extensions to populate new `DatabaseSource` property.

* Use `undefined` instead of `null`

Co-authored-by: Kim Santiago <kisantia@microsoft.com>
2022-04-18 11:38:10 -07:00
Kim Santiago
b65a6bd741 update DW target platform name in sql projects (#18843)
* update DW target platform name

* remove Microsoft from target platform names

* fix merge conflict
2022-03-31 15:30:30 -07:00
Leila Lali
459fab256e Sql Proj: Adding a new sqlproj template for SQL dbs (#18636) 2022-03-29 09:06:56 -07:00
Kim Santiago
5f2d8b2bd5 remove sql server 2005 and 2008 as options for sql database projects (#18664)
* remove sql server 2005 and 2008 from target platforms

* also remove 2005 and 2008 from SqlTargetPlatform enum

* fix a windows test
2022-03-10 18:11:49 -08:00
Benjin Dubishar
292e60a767 Apply changes from remote database to sqlproj - sql-database-projects changes (#17738)
* update project from database

* update project from database

* Leftover merge update

* Slight refactor to add vscode entrypoints

* Re-adding leftover schemacompare bits that reference database project changes

* Removing unnecessary function

* Addiung GetDSP command to package.json

* tests and a race condition fix

* remove custom UUID generation code

* swapping awaits for voids on promises

* PR feedback

* PR feedback

* Hide update project command from vscode

* Swapping cross-extension commands for bound extension contract

* Re-adding schema compare radio buttons for sqlproj

* Adding refresh after project update

* Populating list of project scripts just before comparison to avoid missing script errors of project was separately edited

* Adding missing await for okay button enable check

* Correcting schema compare source when populated from a project

* Rename UpdateDataModel to be more clear

* Fix incorrectly changed type

* Added new runComparison schema compare command, hooked up to sqlproj extension

* Added progress indicator for "apply now" option

* moved string literal to constant

* Added missing await

* Setting missing "saveScmpButton" state to fix test

* Revert "Setting missing "saveScmpButton" state to fix test"

This reverts commit 55612c9def24ac9e3398f5bbd153d21d9d3ca37f.

* Removing preemptive resetWindow() call

* general cleanup

* PR feedback

* property renames

* Reverting rename; requires Tools Service change first

* Adding header to updateProject

* Adding missing header

* PR feedback

* adding missing await

* Handing race condition for UI enable

* Fixing broken okay enable case

* Fixing enum comparison wonk

Co-authored-by: Noureldine Yehia <t-nyehia@microsoft.com>
2022-01-11 16:52:09 -08:00
Charles Gagnon
7940814e8d Add GenerateProjectFromOpenApiSpecOptions (#18045)
* wip

* Undo string change

* more changes
2022-01-11 11:57:21 -08:00
Charles Gagnon
d40d6fbe12 Fix publisher for VS Code extensions (#17505) 2021-10-27 10:17:29 -07:00
Alexander Ivanov
b35e78a07f Automatically add intermediate folders for SQL project items. (#16332)
* Automatically add intermediate folders for SQL project items.

While using the SQL database projects through the API, I noticed that project may end up in somewhat inconsistent state, where files will be added to the project, but their parent folders will not. This in turn resulted in failure to remove these folders from project - they will show up in the UI tree, but deleting them will cause an error. In order to align with how Visual Studio manages the projects, this change will ensure that all intermediate folders are present in the project, when new files or folders are added.

While this change improves project "correctness" when accessing it through SQL projects extension APIs, there is still a possibility that someone will open an "incorrect" previously created project. This change does not address it and folder removal may still fail.

* Update the code to never throw on duplicate items when adding files and folders to project.

After a conversation with the sqlproj owners, we agreed that there are no scenarios that would prompt us to throw an error, if duplicate item is being added to the project. Ultimately, the goal of such a request would be to have an item in the project file, which is already present, therefore the call becomes a no-op.

This allowed me to simplify the new code that was ensuring all intermediate folders are present in the project when adding files and folders.
2021-08-03 09:49:11 -07:00
Charles Gagnon
83af84774a Sql Proj VS Code fixes (#16506)
* Sql Proj VS Code fixes

* remove comment
2021-08-01 00:24:28 -07:00
Kim Santiago
f01e9e2fc0 add api to open new project dialog with only one project type with filtered target platforms (#16315) 2021-07-27 10:03:44 -07:00
Kim Santiago
affe3a838b Add target platform as an option in create project api (#16035)
* add target platform as an option in create project api

* add test

* move constant
2021-07-12 15:14:33 -07:00
Alexander Ivanov
c6fec97819 Expose default database collation through 'sql-database-projects' extension API (#15538)
* Expose default database collation through 'sql-database-projects' extension API.

For the purpose of schema conversion we would need to know whether target database is configured as CI or CS. This will be used to produce a warning, if we detect a case-sensitive identifier, but database is configured as CI. In order to support this scenario we need to access `<DefaultCollation/>` property of the project.

This change adds new method to the `ISqlProject` interface that allows to read the value of the project property. There already was similar method for the SQL version/platform (`<DSP/>` property) and while working on the change, I took an opportunity to refactor the way project properties are extracted from the XML. Original code was hardcoded in the `getProjectTargetVersion` and I extracted it into separate `evaluateProjectPropertyValue` helper, that can be used in the future by any getter or access method that is supposed to return a value of the single property. This also allows us to improve the way properties are retrieved from the XML. Today the logic is very rudimentary - we read the first matching XML element with the required name. This is not correct as it does not verify the parent to be `<PropertyGroup/>`, neither it evaluates the `Condition` attributes nor property value itself. I did not invest in this, but added a TODO there explaining that the method may not perform as expected.

After the helper method was added, I updated the existing `getProjectTargetVersion` method to leverage it. The only complication here was the error throwing logic, as it was using custom error message. I preserved that, as there were tests verifying it already. For the new accessor method I did not introduce a special error message and rely on generic one I defined for use within the helper method. Additionally, for the collation we return default value of `SQL_Latin1_General_CP1_CI_AS`, if project does not have the property defined. This is what SSDT for Visual Studio shows in the UI when property is missing and I decided to align with that.

Finally, I added tests for both - original `getProjectTargetVersion` and new collation extraction method to make sure they work as expected. While working on the tests, I've noticed complaints that some rejected promises were not awaited. I added missing `await`s.
2021-05-28 12:42:21 -07:00
Alexander Ivanov
676296fbbb Allow to ignore duplicate entires when adding files to SQL project. (#15332)
This change introduces new boolean flag for `addToProject`, `addScriptItem` and `addFolderItem` APIs that allows to skip files/folders if they are already included in the project file. Original behavior was to throw an error if duplicate entry is encountered, so I kept that as a default (new flag is not set).

I started by fixing the original behavior, as it was not always working as expected. In our extension that relies on `addToProject` API we've hit an issue where duplicate items were added and no errors were thrown. There was a test for this scenario, but unfortunately the test had few bugs in it as well, so I addressed that first. First issue with the test code was missing `await` on the `testUtils.shouldThrowSpecificError` calls, so test was not actually testing anything. After adding missing keywords, I hit an issue where exception was not thrown, but this turned out to be different issue, compared to what we were hitting. In the test code, it was using the very first folder from the generate list of test entires. This folder wass actually the root of the project (where sqlproj file is located), and `addToProject` API had a special case to ignore the root. This means neither first call nor second call was actually adding anything to the project and no errors were produced. I fixed this problem by using next available folder in the generated files list.

After addressing the test code I could not reproduce the issue that we were seeing with duplicate entires being added, everything was working as expected and errors were thrown. I started adding more tests that better resemble our production scenario - add files in subfolders, add files to existing project, rather than a new one. Finally I was able to reproduce the problem in tests when adding a file in a subfolder to an existing project. After investigation this turned out to be an issue with mismatch in how `relativePath` is maintained within the `FileProjectEntry`. When loading an existing project, `relativePath` is populated based on the value of the `Include` attribute of the `Build` item. This attribute is normalized to Windows-style path, using `\`, so for nested file you will have `folder\file.sql`. When adding new item to the project, one could pass either Windows or Unix-style path (`folder/file.sql`), so the path comparison between loaded Windows-style path and newly added Unix-style path was failing, resulting in them being treated as different items. In fact, `addToProject` API that we were using was relying on `Uri` helpers to extract relative path, thus the path was forced to be Unix-style and path was never the same as the loaded one. After this discovery I added a dedicated test to validate the round-trip of the `relativePath` for serialized and desirialized project file.

In order to address this problem, I updated the factory method `createFileProjectEntry` to always run `utils.convertSlashesForSqlProj` on the relative path to ensure we have Windows-style path stored in there. I also optimized the helper code slightly to not do split/join, if there are no split points in the input string, which should eliminate unnecessary array instantiation. It is worth mentioning that I had to normalize the input relative paths in the `addScriptItem` and `addFolderItem` APIs, because there is no guarantee that they will be Windows-style when we try to compare them to `relativePath` of the existing project items.

Finally I was able to add a simply flag and update the condition to return existing record, if duplicates were allowed. I also updated typings file for the extension and added tests to cover this scenario.
2021-05-10 13:59:24 -07:00
Kim Santiago
da37cf6ec6 Expose sql project apis (#15239)
* make project variables private and add getters

* expose project in sqlproj.d.ts

* add more comments

* change to ISqlProject
2021-04-27 17:35:27 -07:00
Kim Santiago
c05cece683 Expose adding files and folders in sql database projects (#14391)
* expose addToProject in dataworkspace.d.ts

* remove changes in data workspace extension

* add sqldbproj.d.ts

* change list to be Uris instead of strings

* don't add files/folders if any don't exist

* fix test on windows
2021-02-23 18:15:38 -08:00