DataConnectors icon indicating copy to clipboard operation
DataConnectors copied to clipboard

"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign key constraints."

Open cchoi-solver opened this issue 5 years ago • 2 comments

Hi,

I'm creating a DataConnector to my company's custom REST/JSON API. The API has functions to list what tables a login has access to, and to describe the schema of a passed in table, in addition to, of course,returning a table.

The schema endpoint returns the column name and "varchar" "nvachar" "varbinary" so forth, because the API is internally backed by a SQL Server instance. From M, I have a function that turns "varbinary" into "type nullable Binary.Type", "nvarchar" to "type nullable Text.Type" and so forth. If the schema endpoint doesn't return schema for a table, I don't add the table to the NavigationTable.

I use the SchemaTransformFunction that was in the 6th TripPin sample to enforce the schema for the data returned from the API, then I pass that table to Table.NavigationTable, after adding the other columns per the TripPin sample.

I have a query querying my "tables" endpoint in my DataConnector project, so that when I run the DataConnector in Visual Studio, I query all the tables that the login I pass has access to.

Whenever I run my DataConnector in Visual Studio, it returns the NavigationTable in the M Query Output but then says the "Failed to enable constraints" error.

Also, when I use the connector within PBI desktop, before I enforced schema, per https://docs.microsoft.com/en-us/power-bi/desktop-create-and-manage-relationships I was able to get automatic relationships without pushing Autodetect, but now I have to click on Autodetect.

I'm curious what that "failed to enable constraints" error is, however I would like to know why I have to push Autodetect now that I enforce schema.

Thanks!

cchoi-solver avatar Aug 21 '18 16:08 cchoi-solver