Skip to content

Commit 9cf1efe

Browse files
committed
Explicitly cast TopicID
When doing a comparison, the `AttributeValue` was implicitly being cast from `VARCHAR(255)` to `INT`. In our scenarios, this shouldn't be a problem. But because it could result in data loss if the `ParentID` field is not (correctly) set to an integer, that raises a warning. To avoid this—and to provide a very trivial performance improvement—we're explicitly converting the `TopicID` from `INT` to `VARCHAR(255)`. This yields no data loss, and allows the two fields to be quickly compared to one another.
1 parent 791486e commit 9cf1efe

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

OnTopic.Data.Sql.Database/Stored Procedures/ValidateHierarchy.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ SELECT TopicID,
9090
AttributeValue
9191
FROM Attributes
9292
WHERE AttributeKey = 'ParentID'
93-
AND AttributeValue != dbo.GetParentID(TopicID)
93+
AND AttributeValue != CAST(dbo.GetParentID(TopicID) AS VARCHAR(255))

0 commit comments

Comments
 (0)