From ff7565d4fb40a4635f89da206f243b36172c7221 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Sun, 24 Jul 2022 13:15:31 -0700 Subject: [PATCH] Map IVsDataView well-known type Part of #23, fixes #27 --- .../MappedObjectTests.cs | 30 +++++++++++++++++++ VS.Data.Sqlite/SqliteObjectSupport.xml | 20 +++++++++++++ 2 files changed, 50 insertions(+) diff --git a/VS.Data.Sqlite.IntegrationTests/MappedObjectTests.cs b/VS.Data.Sqlite.IntegrationTests/MappedObjectTests.cs index aa5fc6e..ce893f7 100644 --- a/VS.Data.Sqlite.IntegrationTests/MappedObjectTests.cs +++ b/VS.Data.Sqlite.IntegrationTests/MappedObjectTests.cs @@ -4,6 +4,7 @@ using Microsoft.VisualStudio.Data.Services; using Microsoft.VisualStudio.Data.Services.RelationalObjectModel; using Microsoft.VisualStudio.Data.Services.SupportEntities; +using Microsoft.VisualStudio.LanguageServer.Client; using Microsoft.VisualStudio.Shell; using Xunit; @@ -110,4 +111,33 @@ public void Can_select_tables_with_restrictions() tables, t => Assert.Equal("A", t.Name)); } + + [VsFact] + public void Can_select_views() + { + var connectionFactory = (IVsDataConnectionFactory)ServiceProvider.GlobalProvider.GetService(typeof(IVsDataConnectionFactory)); + var connection = connectionFactory.CreateConnection( + PackageGuids.guidSqliteDataProvider, + "Data Source=:memory:", + encryptedString: false); + + var command = (IVsDataCommand)connection.GetService(typeof(IVsDataCommand)); + command.ExecuteWithoutResults(@" + CREATE VIEW view1 AS + SELECT 1 AS Value; + "); + + var selector = (IVsDataMappedObjectSelector)connection.GetService(typeof(IVsDataMappedObjectSelector)); + var views = selector.SelectMappedObjects(); + + Assert.Collection( + views, + v => + { + Assert.Equal("main", v.Catalog); + Assert.Null(v.Schema); + Assert.Equal("view1", v.Name); + Assert.Equal(new object[] { "main", null, "view1" }, v.Identifier); + }); + } } diff --git a/VS.Data.Sqlite/SqliteObjectSupport.xml b/VS.Data.Sqlite/SqliteObjectSupport.xml index 26291d7..6394cdd 100644 --- a/VS.Data.Sqlite/SqliteObjectSupport.xml +++ b/VS.Data.Sqlite/SqliteObjectSupport.xml @@ -242,5 +242,25 @@ + + + + + + + + + + + + + + + + + + + +