@@ -465,8 +465,8 @@ def _build_create_comment_table_exp(
465465 template = dedent ("""
466466 DECLARE @comment sql_variant = {comment};
467467 DECLARE @property_name VARCHAR(128) = 'MS_Description';
468- DECLARE @schema_name VARCHAR(128) = ' {schema_name}' ;
469- DECLARE @object_name VARCHAR(128) = ' {object_name}' ;
468+ DECLARE @schema_name VARCHAR(128) = {schema_name};
469+ DECLARE @object_name VARCHAR(128) = {object_name};
470470 DECLARE @object_kind VARCHAR(128) = '{object_kind}';
471471 DECLARE @existing sql_variant;
472472
@@ -486,11 +486,13 @@ def _build_create_comment_table_exp(
486486 END
487487 """ )
488488 tsql_text = template .format (
489- comment = exp .Literal .string (table_comment ).sql (dialect = self .dialect )
490- if table_comment is not None
491- else "NULL" ,
492- schema_name = table .db if table .db else "dbo" ,
493- object_name = table .name ,
489+ comment = exp .Literal .string (table_comment or "NULL" ).sql (
490+ dialect = self .dialect , identify = False
491+ ),
492+ schema_name = exp .Literal .string (table .db or "dbo" ).sql (
493+ dialect = self .dialect , identify = False
494+ ),
495+ object_name = exp .Literal .string (table .name ).sql (dialect = self .dialect , identify = False ),
494496 object_kind = table_kind ,
495497 )
496498 return tsql_text
@@ -501,10 +503,10 @@ def _build_create_comment_column_exp(
501503 template = dedent ("""
502504 DECLARE @comment sql_variant = {comment};
503505 DECLARE @property_name VARCHAR(128) = 'MS_Description';
504- DECLARE @schema_name VARCHAR(128) = ' {schema_name}' ;
505- DECLARE @object_name VARCHAR(128) = ' {object_name}' ;
506+ DECLARE @schema_name VARCHAR(128) = {schema_name};
507+ DECLARE @object_name VARCHAR(128) = {object_name};
506508 DECLARE @object_kind VARCHAR(128) = '{object_kind}';
507- DECLARE @column_name VARCHAR(128) = ' {column_name}' ;
509+ DECLARE @column_name VARCHAR(128) = {column_name};
508510 DECLARE @existing sql_variant;
509511
510512 SELECT TOP 1 @existing = CAST(VALUE AS NVARCHAR) FROM fn_listextendedproperty(@property_name, 'schema', @schema_name, @object_kind, @object_name, 'column', @column_name);
@@ -522,14 +524,17 @@ def _build_create_comment_column_exp(
522524 EXEC sp_updateextendedproperty @property_name, @comment, 'schema', @schema_name, @object_kind, @object_name, 'column', @column_name;
523525 END
524526 """ )
527+
525528 tsql_text = template .format (
526- comment = exp .Literal .string (column_comment ).sql (dialect = self .dialect )
527- if column_comment is not None
528- else "NULL" ,
529- schema_name = table .db if table .db else "dbo" ,
530- object_name = table .name ,
529+ comment = exp .Literal .string (column_comment or "NULL" ).sql (
530+ dialect = self .dialect , identify = False
531+ ),
532+ schema_name = exp .Literal .string (table .db or "dbo" ).sql (
533+ dialect = self .dialect , identify = False
534+ ),
535+ object_name = exp .Literal .string (table .name ).sql (dialect = self .dialect , identify = False ),
531536 object_kind = table_kind ,
532- column_name = column_name ,
537+ column_name = exp . Literal . string ( column_name ). sql ( dialect = self . dialect , identify = False ) ,
533538 )
534539
535540 return tsql_text
0 commit comments