From b9be10a24f8540d013671143243561c02e3ac744 Mon Sep 17 00:00:00 2001 From: Richard Lavey Date: Fri, 12 Nov 2021 16:29:51 +0000 Subject: [PATCH] #23 Only create string_split if DB level doesn't have it Signed-off-by: Richard Lavey --- sql/user.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/user.go b/sql/user.go index 03ad8cc..cd4a33b 100644 --- a/sql/user.go +++ b/sql/user.go @@ -120,7 +120,7 @@ func (c *Connector) CreateUser(ctx context.Context, database string, user *model 'DEFAULT_LANGUAGE = ' + Coalesce(QuoteName(@language), 'NONE') END END - IF objectproperty(object_id('String_Split'), 'isProcedure') IS NULL + IF exists (select compatibility_level FROM sys.databases where name = db_name() and compatibility_level < 130) BEGIN DECLARE @sql NVARCHAR(MAX); SET @sql = N'Create FUNCTION [dbo].[String_Split] @@ -191,7 +191,7 @@ func (c *Connector) UpdateUser(ctx context.Context, database string, user *model BEGIN SET @stmt = @stmt + ', DEFAULT_LANGUAGE = ' + Coalesce(QuoteName(@language), 'NONE') END - IF objectproperty(object_id('String_Split'), 'isProcedure') IS NULL + IF exists (select compatibility_level FROM sys.databases where name = db_name() and compatibility_level < 130) BEGIN DECLARE @sql NVARCHAR(MAX); SET @sql = N'Create FUNCTION [dbo].[String_Split]