From f0e781bc9e986f6b2777337ad358a430e25d477e Mon Sep 17 00:00:00 2001 From: JeremyCaney Date: Tue, 8 Sep 2020 19:38:33 -0700 Subject: [PATCH] Removed legacy functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `SimpleIntListToTbl` and `Split` functions were previously used by stored procedures to parse string delimited lists of e.g. attributes into temporary tables. In a previous update to the schema, this functionality was replaced with user-defined table-valued types—namely `TopicList` and `AttributeValues`, and thus these are no longer utilized. While these were indroduced previously, they were never publicly documented and we have no expectation that implementers will be calling these directly. As such, while this is technically a breaking change, I'm considering that acceptable since these should be understood to be internal objects, and were never called directly by the OnTopic library. Further, there is no need to call them from application code, as their use is of exclusively benefit to SQL scripts themselves. --- .../Functions/SimpleIntListToTbl.sql | 53 ------------------- OnTopic.Data.Sql.Database/Functions/Split.sql | 40 -------------- .../OnTopic.Data.Sql.Database.sqlproj | 2 - 3 files changed, 95 deletions(-) delete mode 100644 OnTopic.Data.Sql.Database/Functions/SimpleIntListToTbl.sql delete mode 100644 OnTopic.Data.Sql.Database/Functions/Split.sql diff --git a/OnTopic.Data.Sql.Database/Functions/SimpleIntListToTbl.sql b/OnTopic.Data.Sql.Database/Functions/SimpleIntListToTbl.sql deleted file mode 100644 index 65b09ce7..00000000 --- a/OnTopic.Data.Sql.Database/Functions/SimpleIntListToTbl.sql +++ /dev/null @@ -1,53 +0,0 @@ --------------------------------------------------------------------------------------------------------------------------------- --- SIMPLE INT LIST TO TABLE (FUNCTION) --------------------------------------------------------------------------------------------------------------------------------- --- Given a comma delimited list of integers, such as TopicIDs, parses them into a table. Similar to the Split function, but more --- specialized. That said, we should prefer using user-defined table valued types to relay lists of values, such as the --- TopicList type. --------------------------------------------------------------------------------------------------------------------------------- -CREATE -FUNCTION [dbo].[SimpleIntListToTbl] ( - @list NVARCHAR(MAX) -) -RETURNS @tbl TABLE ( - number INT NOT NULL -) -AS - -BEGIN - - ------------------------------------------------------------------------------------------------------------------------------ - -- DECLARE AND DEFINE VARIABLES - ------------------------------------------------------------------------------------------------------------------------------ - DECLARE @pos INT = 0, - @nextpos INT = 1, - @valuelen INT, - @value VARCHAR(20) - - ------------------------------------------------------------------------------------------------------------------------------ - -- CREATE TABLE - ------------------------------------------------------------------------------------------------------------------------------ - WHILE @nextpos > 0 - BEGIN - SELECT @nextpos = charindex(',', @list, @pos + 1) - SELECT @valuelen = CASE - WHEN @nextpos > 0 - THEN @nextpos - ELSE len(@list) + 1 - END - @pos - 1 - IF @valuelen = 0 - CONTINUE - INSERT @tbl ( - number - ) - VALUES ( convert(int, substring(@list, @pos + 1, @valuelen)) - ) - SELECT @pos = @nextpos - END - - ------------------------------------------------------------------------------------------------------------------------------ - -- RETURN VALUES - ------------------------------------------------------------------------------------------------------------------------------ - RETURN - -END \ No newline at end of file diff --git a/OnTopic.Data.Sql.Database/Functions/Split.sql b/OnTopic.Data.Sql.Database/Functions/Split.sql deleted file mode 100644 index 32704ccb..00000000 --- a/OnTopic.Data.Sql.Database/Functions/Split.sql +++ /dev/null @@ -1,40 +0,0 @@ --------------------------------------------------------------------------------------------------------------------------------- --- SPLIT (FUNCTION) --------------------------------------------------------------------------------------------------------------------------------- --- Given a string and a delimited, will parse the string by the delimiter and return a table as a result. Preferably, we should --- instead use user-defined table valued types, such as AttributeValues and TopicList. --------------------------------------------------------------------------------------------------------------------------------- -CREATE -FUNCTION [dbo].[Split] ( - @s varchar(8000), - @sep char(1) -) -RETURNS TABLE -AS - -RETURN( - - ------------------------------------------------------------------------------------------------------------------------------ - -- SPLIT INPUT - ------------------------------------------------------------------------------------------------------------------------------ - WITH Pieces( - pn, - start, - stop - ) - AS ( - SELECT 1, - 1, - CHARINDEX(@sep, @s) - UNION ALL - SELECT pn + 1, - stop + 1, - CHARINDEX(@sep, @s, stop + 1) - FROM Pieces - WHERE stop > 0 - ) - SELECT pn, - SUBSTRING(@s, start, CASE WHEN stop > 0 THEN stop-start ELSE 8000 END) AS s - FROM Pieces - -) \ No newline at end of file diff --git a/OnTopic.Data.Sql.Database/OnTopic.Data.Sql.Database.sqlproj b/OnTopic.Data.Sql.Database/OnTopic.Data.Sql.Database.sqlproj index 79b821d6..cb5da1ed 100644 --- a/OnTopic.Data.Sql.Database/OnTopic.Data.Sql.Database.sqlproj +++ b/OnTopic.Data.Sql.Database/OnTopic.Data.Sql.Database.sqlproj @@ -100,8 +100,6 @@ - -