Skip to content

Commit ff7565d

Browse files
committed
Map IVsDataView well-known type
Part of #23, fixes #27
1 parent 671098b commit ff7565d

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

VS.Data.Sqlite.IntegrationTests/MappedObjectTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Microsoft.VisualStudio.Data.Services;
55
using Microsoft.VisualStudio.Data.Services.RelationalObjectModel;
66
using Microsoft.VisualStudio.Data.Services.SupportEntities;
7+
using Microsoft.VisualStudio.LanguageServer.Client;
78
using Microsoft.VisualStudio.Shell;
89
using Xunit;
910

@@ -110,4 +111,33 @@ public void Can_select_tables_with_restrictions()
110111
tables,
111112
t => Assert.Equal("A", t.Name));
112113
}
114+
115+
[VsFact]
116+
public void Can_select_views()
117+
{
118+
var connectionFactory = (IVsDataConnectionFactory)ServiceProvider.GlobalProvider.GetService(typeof(IVsDataConnectionFactory));
119+
var connection = connectionFactory.CreateConnection(
120+
PackageGuids.guidSqliteDataProvider,
121+
"Data Source=:memory:",
122+
encryptedString: false);
123+
124+
var command = (IVsDataCommand)connection.GetService(typeof(IVsDataCommand));
125+
command.ExecuteWithoutResults(@"
126+
CREATE VIEW view1 AS
127+
SELECT 1 AS Value;
128+
");
129+
130+
var selector = (IVsDataMappedObjectSelector)connection.GetService(typeof(IVsDataMappedObjectSelector));
131+
var views = selector.SelectMappedObjects<IVsDataView>();
132+
133+
Assert.Collection(
134+
views,
135+
v =>
136+
{
137+
Assert.Equal("main", v.Catalog);
138+
Assert.Null(v.Schema);
139+
Assert.Equal("view1", v.Name);
140+
Assert.Equal(new object[] { "main", null, "view1" }, v.Identifier);
141+
});
142+
}
113143
}

VS.Data.Sqlite/SqliteObjectSupport.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,5 +242,25 @@
242242
</Property>
243243
</Properties>
244244
</MappedType>
245+
<MappedType name="View" underlyingType="View">
246+
<Selection restrictions="{Name}" ordering="Name" />
247+
<Identifier>
248+
<Part name="Catalog">
249+
<Conversion>
250+
<Calculate expr="'main'" exprType="System.String" />
251+
</Conversion>
252+
</Part>
253+
<Part name="Name" underlyingMember="Name" />
254+
</Identifier>
255+
<Properties>
256+
<Property name="Catalog" isIdentifierPart="true" />
257+
<Property name="Name" isIdentifierPart="true" />
258+
<Property name="IsSystemObject" underlyingMember="Name">
259+
<Conversion>
260+
<Calculate expr="{0} LIKE 'sqlite_%'" exprType="System.Boolean" />
261+
</Conversion>
262+
</Property>
263+
</Properties>
264+
</MappedType>
245265
</MappedTypes>
246266
</DataObjectSupport>

0 commit comments

Comments
 (0)