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
2020-12-07 13:31:59 -08:00
2021-05-04 09:08:36 -07:00
2021-03-31 11:08:45 -07:00
2019-03-15 13:09:45 -07:00
2019-03-20 10:39:09 -07:00
2021-04-16 09:08:34 -07:00
2019-03-15 13:09:45 -07:00
2019-03-19 17:44:35 -07:00
2019-10-22 23:16:11 -07:00
2021-04-27 16:03:56 -07:00
2021-04-16 09:08:34 -07:00
2019-10-18 17:21:40 -07:00
2018-06-05 11:24:51 -07:00

Azure Data Studio

Join the chat at https://gitter.im/Microsoft/sqlopsstudio Build Status Twitter Follow

Azure Data Studio is a data management tool that enables you to work with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.

Download the latest Azure Data Studio release

Platform
Windows User Installer
Windows System Installer
Windows ZIP
macOS ZIP
Linux TAR.GZ
Linux RPM
Linux DEB

Go to our download page for more specific instructions.

Try out the latest insiders build from main:

See the change log for additional details of what's in this release. Go to our download page for more specific instructions.

Feature Highlights

  • Cross-Platform DB management for Windows, macOS and Linux with simple XCopy deployment
  • SQL Server Connection Management with Connection Dialog, Server Groups, Azure Integration and Registered Servers
  • Object Explorer supporting schema browsing and contextual command execution
  • T-SQL Query Editor with advanced coding features such as autosuggestions, error diagnostics, tooltips, formatting and peek definition
  • Query Results Viewer with advanced data grid supporting large result sets, export to JSON\CSV\Excel, query plan and charting
  • Management Dashboard supporting customizable widgets with drill-through actionable insights
  • Visual Data Editor that enables direct row insertion, update and deletion into tables
  • Backup and Restore dialogs that enables advanced customization and remote filesystem browsing, configured tasks can be executed or scripted
  • Task History window to view current task execution status, completion results with error messages and task T-SQL scripting
  • Scripting support to generate CREATE, SELECT, ALTER and DROP statements for database objects
  • Workspaces with full Git integration and Find In Files support to managing T-SQL script libraries
  • Modern light-weight shell with theming, user settings, full-screen support, integrated terminal and numerous other features

Here are some of these features in action.

Contributing

If you are interested in fixing issues and contributing directly to the code base, please see the document How to Contribute, which covers the following:

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Localization

Azure Data Studio is localized into 10 languages: French, Italian, German, Spanish, Simplified Chinese, Traditional Chinese, Japanese, Korean, Russian, and Portuguese (Brazil). The language packs are available in the Extension Manager marketplace. Simply, search for the specific language using the extension marketplace and install. Once you install the selected language, Azure Data Studio will prompt you to restart with the new language.

Privacy Statement

The Microsoft Enterprise and Developer Privacy Statement describes the privacy statement of this software.

Contributions and "Thank You"

We would like to thank all our users who raised issues, and in particular the following users who helped contribute fixes:

  • eulercamposbarros for Prevent connections from moving on click (#7528)
  • AlexFsmn for Fixed issue where task icons got hidden if text was too long
  • jamesrod817 for Tempdb (#7022)
  • dzsquared for fix(snippets): ads parenthesis to sqlcreateindex snippet #7020
  • devmattrick for Update row count as updates are received #6642
  • mottykohn for In Message panel onclick scroll to line #6417
  • Stevoni for Corrected Keyboard Shortcut Execution Issue #5480
  • yamatoya for fix the format #4899
  • GeoffYoung for Fix sqlDropColumn description #4422
  • AlexFsmn for Added context menu for DBs in explorer view to backup & restore db. #2277
  • sadedil for Missing feature request: Save as XML #3729
  • gbritton1 for Removed reference to object explorer #3463
  • Tarig0 for Add Routine_Type to CreateStoredProc fixes #3257 (#3286)
  • oltruong for typo fix #3025'
  • Thomas-S-B for Removed unnecessary IErrorDetectionStrategy #749
  • Thomas-S-B for Simplified code #750
  • rdaniels6813 for Add query plan theme support #3031
  • Ruturaj123 for Fixed some typos and grammatical errors #3027
  • PromoFaux for Use emoji shortcodes in CONTRIBUTING.md instead of <20> #3009
  • ckaczor for Fix: DATETIMEOFFSET data types should be ISO formatted #714
  • hi-im-T0dd for Fixed sync issue with my forked master so this commit is correct #2948
  • hi-im-T0dd for Fixed when right clicking and selecting Manage-correct name displays #2794
  • philoushka for center the icon #2760
  • anthonypants for Typo #2775
  • kstolte for Fix Invalid Configuration in Launch.json #2789
  • kstolte for Fixing a reference to SQL Ops Studio #2788
  • AlexFsmn Feature: Ability to add connection name #2332
  • AlexFsmn Disabled connection name input when connecting to a server. #2566
  • SebastianPfliegel Added more saveAsCsv options #2099
  • ianychoi Fixes a typo: Mimunum -> Minimum #1994
  • AlexFsmn Fixed bug where proper file extension wasn't appended to the filename. #2151
  • AlexFsmn Added functionality for adding any file to import wizard #2329
  • AlexFsmn Fixed background issue when copying a chart to clipboard #2215
  • AlexFsmn Fixed problem where vertical charts didn't display labels correctly. #2263
  • AlexFsmn Fixed Initial values for charts to match visuals #2266
  • AlexFsmn Renamed chart option labels #2264
  • AlexFsmn Added feature for the opening file after exporting to CSV/XLS/JSON & query files #2216
  • AlexFsmm Get Connection String should copy to clipboard #2175
  • lanceklinger Fix for double-clicking column handle in results table #1504
  • westerncj for Removed duplicate contribution from README.md (#753)
  • ntovas for Fix for duplicate extensions shown in "Save File" dialog. (#779)
  • SebastianPfliegel for Add cursor snippet (#475)
  • mikaoelitiana for the fix: revert README and CONTRIBUTING after last VSCode merge (#574)
  • alextercete for Reinstate menu item to install from VSIX (#682)
  • alextercete for Fix "No extension gallery service configured" error (#427)
  • mwiedemeyer for Fix #58: Default sort order for DB size widget (#111)
  • AlexTroshkin for Show disconnect in context menu only when connectionProfile connected (#150)
  • AlexTroshkin for Fix #138: Invalid syntax color highlighting (identity not highlighting) (#140))
  • stebet for Fix #153: Fixing sql snippets that failed on a DB with a case-sensitive collation. (#152)
  • SebastianPfliegel Remove sqlExtensionHelp (#312)
  • olljanat for Implemented npm version check (#314)
  • Adam Machanic for helping with the whoisactive extension

And of course, we'd like to thank the authors of all upstream dependencies. Please see a full list in the ThirdPartyNotices.txt

License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the Source EULA.

Description
No description provided
Readme 335 MiB
Languages
TypeScript 64.8%
jsonc 29%
JavaScript 1.8%
CSS 1.3%
C 1.2%
Other 1.7%