Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCIMSchemaAttributeModel does not always have SchemaId column set #25

Closed
bzuidgeest opened this issue Mar 13, 2020 · 2 comments
Closed
Labels
bug Something isn't working
Projects

Comments

@bzuidgeest
Copy link

bzuidgeest commented Mar 13, 2020

It seems that in SCIMSchemaAttributeModel, the SchemaId column is not set for subattributes with the schema Id but just null. I can use a recursive query to get the complete list of attributes in a schema. But having schemaId always filled with schemaId would make getting a complete attribute list for a schema much more efficient.

Same goes for RepresentationId in SCIMRepresentationAttributeLst. If it was filled in everywhere, I could do the query for getting all attributes without recursion, making the example query below more simple.

;WITH RepresentationAttribute 
AS
(
    SELECT * 
	FROM [SCIMRepresentationAttributeLst]
	WHERE RepresentationId IS NOT NULL
    
	UNION ALL

    SELECT child.Id,
		child.ParentId,
		child.SchemaAttributeId,
		CASE WHEN Child.RepresentationId IS NULL THEN parent.RepresentationId ELSE Child.RepresentationId END AS RepresentationId  
	FROM [SCIMRepresentationAttributeLst] AS child
		INNER JOIN RepresentationAttribute AS parent ON child.parentId = parent.id
)
SELECT 
	[SCIMRepresentationLst].Id,
	[SCIMRepresentationLst].ExternalId,
	RepresentationAttribute.*
	,SCIMRepresentationAttributeValueLst.*
	,SCIMSchemaAttributeModel.*
FROM [SCIM].[dbo].[SCIMRepresentationLst]
	inner join RepresentationAttribute on [SCIMRepresentationLst].Id = RepresentationAttribute.RepresentationId
	inner join SCIMSchemaAttributeModel on RepresentationAttribute.SchemaAttributeId = SCIMSchemaAttributeModel.Id
	left outer join SCIMRepresentationAttributeValueLst ON RepresentationAttribute.Id = SCIMRepresentationAttributeValueLst.SCIMRepresentationAttributeId

This might not mean much for the .NET side of things, but might be useful for further processing on the SQL side. Also if this fouls something on the .NET side of things just close as wont implement as this is not that important

@simpleidserver simpleidserver added the bug Something isn't working label Mar 13, 2020
@simpleidserver simpleidserver added this to In Progress in 1.1.0 Mar 13, 2020
@simpleidserver
Copy link
Owner

The SchemaId and RepresentationId columns have been set, you can take the latest version from the branch origin/release/1.1.0.
The release number has been upgrated because we made breaking changes on the database.

Note : the table SCIMSchemaAttribute must be truncated before launching the solution, otherwise the SchemaId column will not be set with the correct value.

@bzuidgeest
Copy link
Author

I have tested it and now I can simply do

SELECT 
	[SCIMRepresentationLst].Id,
	[SCIMRepresentationLst].ExternalId,
	[SCIMRepresentationAttributeLst].*
	,SCIMRepresentationAttributeValueLst.*
	,SCIMSchemaAttributeModel.*
FROM [SCIM].[dbo].[SCIMRepresentationLst]
	inner join [SCIMRepresentationAttributeLst] on [SCIMRepresentationLst].Id = [SCIMRepresentationAttributeLst].RepresentationId
	inner join SCIMSchemaAttributeModel on [SCIMRepresentationAttributeLst].SchemaAttributeId = SCIMSchemaAttributeModel.Id
	left outer join SCIMRepresentationAttributeValueLst ON [SCIMRepresentationAttributeLst].Id = SCIMRepresentationAttributeValueLst.SCIMRepresentationAttributeId
order by ExternalId

to get all attributes for any model. Much simpler.

@simpleidserver simpleidserver moved this from In Progress to Done in 1.1.0 Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
1.1.0
Done
Development

No branches or pull requests

2 participants