@@ -240,7 +240,7 @@ public async Task SQL_CdpTabular_GetTables2()
240
240
// For SQL we don't have relationships
241
241
bool b = sqlTable . RecordType . TryGetFieldExternalTableName ( "ProductModelID" , out string externalTableName , out string foreignKey ) ;
242
242
Assert . False ( b ) ;
243
-
243
+
244
244
testConnector . SetResponseFromFiles ( @"Responses\SQL GetSchema ProductModel.json" ) ;
245
245
b = sqlTable . RecordType . TryGetFieldType ( "ProductModelID" , out FormulaType productModelID ) ;
246
246
@@ -251,6 +251,41 @@ public async Task SQL_CdpTabular_GetTables2()
251
251
Assert . Equal ( "ProductID" , string . Join ( "|" , GetPrimaryKeyNames ( sqlTable . RecordType ) ) ) ;
252
252
}
253
253
254
+ [ Fact ]
255
+ public async Task SQL_CdpTabular_GetTables3 ( )
256
+ {
257
+ using var testConnector = new LoggingTestServer ( null /* no swagger */ , _output ) ;
258
+ var config = new PowerFxConfig ( Features . PowerFxV1 ) ;
259
+ var engine = new RecalcEngine ( config ) ;
260
+
261
+ ConsoleLogger logger = new ConsoleLogger ( _output ) ;
262
+ using var httpClient = new HttpClient ( testConnector ) ;
263
+ string connectionId = "29941b77eb0a40fe925cd7a03cb85b40" ;
264
+ string jwt = "eyJ0eX..." ;
265
+ using var client = new PowerPlatformConnectorClient ( "49970107-0806-e5a7-be5e-7c60e2750f01.12.common.firstrelease.azure-apihub.net" , "49970107-0806-e5a7-be5e-7c60e2750f01" , connectionId , ( ) => jwt , httpClient ) { SessionId = "8e67ebdc-d402-455a-b33a-304820832383" } ;
266
+
267
+ testConnector . SetResponseFromFile ( @"Responses\SQL GetDatasetsMetadata.json" ) ;
268
+ DatasetMetadata dm = await CdpDataSource . GetDatasetsMetadataAsync ( client , $ "/apim/sql/{ connectionId } ", CancellationToken . None , logger ) ;
269
+
270
+ Assert . NotNull ( dm ) ;
271
+ Assert . Null ( dm . Blob ) ;
272
+
273
+ // Use of Unicode characters in DataSource
274
+ CdpDataSource cds = new CdpDataSource ( "pfxdev-sql.database.windows.net,Aßþ" ) ;
275
+
276
+ testConnector . SetResponseFromFiles ( @"Responses\SQL GetDatasetsMetadata.json" , @"Responses\SQL GetTables SampleDB.json" ) ;
277
+ IEnumerable < CdpTable > tables = await cds . GetTablesAsync ( client , $ "/apim/sql/{ connectionId } ", CancellationToken . None , logger ) ;
278
+
279
+ Assert . NotNull ( tables ) ;
280
+
281
+ CdpTable connectorTable = tables . First ( t => t . DisplayName == "Customer" ) ;
282
+ Assert . False ( connectorTable . IsInitialized ) ;
283
+
284
+ testConnector . SetResponseFromFile ( @"Responses\SQL Server Load Customers DB.json" ) ;
285
+ await connectorTable . InitAsync ( client , $ "/apim/sql/{ connectionId } ", CancellationToken . None , logger ) ;
286
+ Assert . True ( connectorTable . IsInitialized ) ;
287
+ }
288
+
254
289
[ Fact ]
255
290
public async Task SQL_CdpTabular_JoinCapabilityTest ( )
256
291
{
@@ -264,23 +299,23 @@ public async Task SQL_CdpTabular_JoinCapabilityTest()
264
299
string jwt = "eyJ0eXAiOiJKSuA..." ;
265
300
using var client = new PowerPlatformConnectorClient ( "dac64a92-df6a-ee6e-a6a2-be41a923e371.15.common.tip1002.azure-apihub.net" , "dac64a92-df6a-ee6e-a6a2-be41a923e371" , connectionId , ( ) => jwt , httpClient ) { SessionId = "8e67ebdc-d402-455a-b33a-304820832383" } ;
266
301
267
- string realTableName = "Product" ;
268
-
302
+ string realTableName = "Product" ;
303
+
269
304
CdpDataSource cds = new CdpDataSource ( "default,default" ) ;
270
305
271
306
testConnector . SetResponseFromFiles ( @"Responses\SQL GetDatasetsMetadata.json" , @"Responses\SQL GetTables SampleDB.json" ) ;
272
307
IEnumerable < CdpTable > tables = await cds . GetTablesAsync ( client , $ "/apim/sql/{ connectionId } ", CancellationToken . None , logger ) ;
273
-
308
+
274
309
CdpTable table = tables . First ( t => t . DisplayName == realTableName ) ;
275
-
310
+
276
311
testConnector . SetResponseFromFiles ( @"Responses\SQL GetSchema Products v2.json" ) ;
277
312
await table . InitAsync ( client , $ "/apim/sql/{ connectionId } ", CancellationToken . None , logger ) ;
278
313
Assert . True ( table . IsInitialized ) ;
279
314
280
315
CdpTableValue sqlTable = table . GetTableValue ( ) ;
281
316
Assert . True ( sqlTable . _tabularService . IsInitialized ) ;
282
317
Assert . True ( sqlTable . IsDelegable ) ;
283
-
318
+
284
319
HashSet < IExternalTabularDataSource > ads = sqlTable . Type . _type . AssociatedDataSources ;
285
320
Assert . NotNull ( ads ) ;
286
321
Assert . Single ( ads ) ;
@@ -645,7 +680,7 @@ private static IEnumerable<string> GetPrimaryKeyNames(RecordType rt)
645
680
646
681
[ Fact ]
647
682
public async Task SF_CdpTabular_GetTables ( )
648
- {
683
+ {
649
684
using var testConnector = new LoggingTestServer ( null /* no swagger */ , _output ) ;
650
685
var config = new PowerFxConfig ( Features . PowerFxV1 ) ;
651
686
var engine = new RecalcEngine ( config ) ;
@@ -942,7 +977,7 @@ public async Task ZD_CdpTabular_GetTables()
942
977
Assert . True ( zdTable . _tabularService . IsInitialized ) ;
943
978
Assert . True ( zdTable . IsDelegable ) ;
944
979
945
- Assert . Equal (
980
+ Assert . Equal (
946
981
"r![active:b, alias:s, created_at:d, custom_role_id:w, details:s, email:s, external_id:s, id:w, last_login_at:d, locale:s, locale_id:w, moderator:b, name:s, notes:s, only_private_comments:b, organization_id:w, " +
947
982
"phone:s, photo:s, restricted_agent:b, role:s, shared:b, shared_agent:b, signature:s, suspended:b, tags:s, ticket_restriction:s, time_zone:s, updated_at:d, url:s, user_fields:s, verified:b]" , ( ( CdpRecordType ) zdTable . RecordType ) . ToStringWithDisplayNames ( ) ) ;
948
983
0 commit comments