Skip to content

feat: add support for table comments in SAP HANA - #11939

Merged
gioboa merged 4 commits into
typeorm:masterfrom
Cprakhar:feat/table-comment-sap
Feb 18, 2026
Merged

gioboa merged 4 commits into
typeorm:masterfrom
Cprakhar:feat/table-comment-sap

Conversation

@Cprakhar

@Cprakhar Cprakhar commented Jan 22, 2026 •

Copy link
Copy Markdown
Collaborator

Close #10621

Summary

This PR introduces support for table comments in SAP HANA.

Changes

  • Implemented the changeTableComment method in the SapQueryRunner.
  • Made minor fixes to the changeTableComment methods in the PostgresQueryRunner and MysqlQueryRunner.
  • Added tests for all supported drivers: SAP, Postgres, MySQL, and MariaDB.

Closes #10621

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links relevant issues as Fixes #10621
  • There are new or updated tests validating the change (tests/**.test.ts)
  • Documentation has been updated to reflect this change (docs/docs/**.md)

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

User description

Summary

This PR introduces support for table comments in SAP HANA.

Changes

  • Implemented the changeTableComment method in the SapQueryRunner.
  • Made minor fixes to the changeTableComment methods in the PostgresQueryRunner and MysqlQueryRunner.
  • Added tests for all supported drivers: SAP, Postgres, MySQL, and MariaDB.

Closes #10621

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • This pull request links relevant issues as Fixes #10621
  • There are new or updated tests validating the change (tests/**.test.ts)
  • Documentation has been updated to reflect this change (docs/docs/**.md)

PR Type

Enhancement


Description

  • Implement changeTableComment method for SAP HANA driver

  • Fix variable naming and state management in MySQL and Postgres drivers

  • Add table comment loading from SAP HANA system tables

  • Add comprehensive tests for table comments across all supported drivers


Diagram Walkthrough

flowchart LR
  A["SAP HANA Driver"] -->|implement changeTableComment| B["Table Comment Support"]
  C["MySQL Driver"] -->|fix variable naming| B
  D["Postgres Driver"] -->|fix variable naming| B
  E["Schema Builder"] -->|enable SAP support| B
  F["System Tables"] -->|load COMMENTS field| B
  B -->|test coverage| G["Functional Tests"]
Loading

File Walkthrough

Relevant files
Enhancement
SapQueryRunner.ts
Implement table and column comment support for SAP             

src/driver/sap/SapQueryRunner.ts

  • Implement changeTableComment method to replace error-throwing stub
  • Add table comment loading from SYS.TABLES.COMMENTS in loadTables
    method
  • Add column comment support in addColumn method
  • Add table comment assignment in table metadata initialization
+71/-7   
RdbmsSchemaBuilder.ts
Enable table comment sync for SAP driver                                 

src/schema-builder/RdbmsSchemaBuilder.ts

  • Add SAP HANA driver to the condition for table comment synchronization
  • Enable automatic table comment updates during schema synchronization
    for SAP
+2/-1     
Bug fix
MysqlQueryRunner.ts
Fix variable naming and state management                                 

src/driver/mysql/MysqlQueryRunner.ts

  • Rename variables from newComment/comment to
    escapedNewComment/escapedComment for clarity
  • Update newTable.comment assignment to use unescaped newComment value
  • Ensure escaped values are used only in SQL queries
+6/-5     
PostgresQueryRunner.ts
Fix variable naming and improve SQL formatting                     

src/driver/postgres/PostgresQueryRunner.ts

  • Rename variables from newComment/comment to
    escapedNewComment/escapedComment
  • Update newTable.comment assignment to use unescaped newComment value
  • Refactor SQL string concatenation to template literals with proper
    escaping
  • Ensure escaped values are used only in SQL queries
+10/-11 
Tests
create-comment.test.ts
Add table comment functional tests                                             

test/functional/query-runner/create-comment.test.ts

  • Add comprehensive test suite for table comment functionality
  • Test table comment creation across SAP, Postgres, MySQL, and MariaDB
    drivers
  • Test comment updates and removal with database verification
  • Test schema synchronization with comment changes
  • Include database-specific query logic for comment retrieval
+127/-0 
Company.ts
Add comment to Company test entity                                             

test/functional/query-runner/entity/Company.ts

  • Add comment property to @Entity decorator with value "This is a
    company entity"
  • Used as test entity for table comment functionality
+1/-1     

@pkg-pr-new

pkg-pr-new Bot commented Jan 22, 2026 •

Copy link
Copy Markdown
  • typeorm-sql-js-example

    npm i https://pkg.pr.new/typeorm/typeorm@11939
    

commit: 49fd096

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jan 22, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 49fd096

CategorySuggestion                                                                                                                                    Impact
Possible issue
Don’t hardcode test schema

In the test file, avoid hardcoding the schema name to 'SYSTEM'. Instead,
dynamically retrieve the current schema to make the tests more robust and
environment-independent.

test/functional/query-runner/create-comment.test.ts [32-36]

+const [{ schema }] = await dataSource.query(
+    `SELECT CURRENT_SCHEMA AS "schema" FROM "SYS"."DUMMY"`,
+)
 const res = await dataSource.query(
-    `SELECT "COMMENTS" FROM "SYS"."TABLES" WHERE "TABLE_NAME" = ? AND "SCHEMA_NAME" = 'SYSTEM'`,
-    [tableName],
+    `SELECT "COMMENTS" FROM "SYS"."TABLES" WHERE "TABLE_NAME" = ? AND "SCHEMA_NAME" = ?`,
+    [tableName, schema],
 )
 return res.length > 0 ? res[0]["COMMENTS"] : undefined
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that hardcoding the schema name 'SYSTEM' in tests can lead to failures in environments with different configurations, and proposes a robust solution to dynamically determine the schema.

Medium
Avoid invalid CREATE TABLE syntax

Verify that CREATE TABLE ... COMMENT '...' is supported on all target SAP HANA
versions. If not, use a separate COMMENT ON TABLE ... query for better
compatibility.

src/driver/sap/SapQueryRunner.ts [3186-3192]

 sql += `)`
-
-if (table.comment) {
-    sql += ` COMMENT ${this.escapeComment(table.comment)}`
-}
 
 return new Query(sql)
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: This suggestion raises a valid compatibility concern about CREATE TABLE ... COMMENT syntax across different SAP HANA versions, proposing a more portable COMMENT ON TABLE query which is a safer approach.

Medium
General
Normalize empty comments consistently

When loading table metadata, normalize null or empty string comments from the
database to undefined. This prevents incorrect comparisons and unnecessary ALTER
TABLE statements during schema synchronization.

src/driver/sap/SapQueryRunner.ts [2751-2757]

 table.database = currentDatabase
 table.schema = dbTable["SCHEMA_NAME"]
-table.comment = dbTable["COMMENTS"]
+table.comment =
+    dbTable["COMMENTS"] === null || dbTable["COMMENTS"] === ""
+        ? undefined
+        : dbTable["COMMENTS"]
 table.name = this.driver.buildTableName(
     dbTable["TABLE_NAME"],
     schema,
 )
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: This suggestion correctly points out a potential issue with how empty comments are handled, which could lead to unnecessary database operations. Normalizing null or empty strings to undefined improves consistency and prevents incorrect diffs during synchronization.

Medium
  • More

Previous suggestions

Suggestions up to commit 1194007
CategorySuggestion                                                                                                                                    Impact
Security
Prevent SQL injection vulnerability

To prevent a potential SQL injection vulnerability, refactor the query
construction in loadTables to use parameterized queries instead of directly
interpolating table and schema names into the SQL string.

src/driver/sap/SapQueryRunner.ts [2660-2687]

 const dbTables: {
     SCHEMA_NAME: string
     TABLE_NAME: string
     COMMENTS: string
 }[] = []
 
 if (!tableNames) {
     const tablesSql = `SELECT "SCHEMA_NAME", "TABLE_NAME", "COMMENTS" FROM "SYS"."TABLES"`
-
     dbTables.push(...(await this.query(tablesSql)))
 } else {
-    const tablesCondition = tableNames
-        .map((tableName) => {
-            let [schema, name] = tableName.split(".")
-            if (!name) {
-                name = schema
-                schema = this.driver.options.schema || currentSchema
-            }
-            return `("SCHEMA_NAME" = '${schema}' AND "TABLE_NAME" = '${name}')`
-        })
-        .join(" OR ")
-
-    const tablesSql =
-        `SELECT "SCHEMA_NAME", "TABLE_NAME", "COMMENTS" FROM "SYS"."TABLES" WHERE ` +
-        tablesCondition
-
-    dbTables.push(...(await this.query(tablesSql)))
+    const conditions = tableNames.map((tableName) => {
+        let [schema, name] = tableName.split(".")
+        if (!name) {
+            name = schema
+            schema = this.driver.options.schema || currentSchema
+        }
+        return { schema, name }
+    })
+    
+    const placeholders = conditions.map(() => `("SCHEMA_NAME" = ? AND "TABLE_NAME" = ?)`).join(" OR ")
+    const parameters = conditions.flatMap(c => [c.schema, c.name])
+    
+    const tablesSql = `SELECT "SCHEMA_NAME", "TABLE_NAME", "COMMENTS" FROM "SYS"."TABLES" WHERE ${placeholders}`
+    dbTables.push(...(await this.query(tablesSql, parameters)))
 }
Suggestion importance[1-10]: 10

__

Why: The suggestion correctly identifies a critical SQL injection vulnerability in the loadTables method and provides a valid fix using parameterized queries, which is a best practice for database security.

High
Suggestions up to commit 70bd716
CategorySuggestion                                                                                                                                    Impact
Security
Prevent SQL injection vulnerability

Fix a SQL injection vulnerability in the loadTables method by using
parameterized queries instead of directly interpolating table and schema names
into the SQL string.

src/driver/sap/SapQueryRunner.ts [2660-2687]

 const dbTables: {
     SCHEMA_NAME: string
     TABLE_NAME: string
     COMMENTS: string
 }[] = []
 
 if (!tableNames) {
     const tablesSql = `SELECT "SCHEMA_NAME", "TABLE_NAME", "COMMENTS" FROM "SYS"."TABLES"`
 
     dbTables.push(...(await this.query(tablesSql)))
 } else {
-    const tablesCondition = tableNames
-        .map((tableName) => {
-            let [schema, name] = tableName.split(".")
-            if (!name) {
-                name = schema
-                schema = this.driver.options.schema || currentSchema
-            }
-            return `("SCHEMA_NAME" = '${schema}' AND "TABLE_NAME" = '${name}')`
-        })
-        .join(" OR ")
+    const conditions: string[] = []
+    const parameters: any[] = []
+    
+    tableNames.forEach((tableName) => {
+        let [schema, name] = tableName.split(".")
+        if (!name) {
+            name = schema
+            schema = this.driver.options.schema || currentSchema
+        }
+        conditions.push(`("SCHEMA_NAME" = ? AND "TABLE_NAME" = ?)`)
+        parameters.push(schema, name)
+    })
 
     const tablesSql =
         `SELECT "SCHEMA_NAME", "TABLE_NAME", "COMMENTS" FROM "SYS"."TABLES" WHERE ` +
-        tablesCondition
+        conditions.join(" OR ")
 
-    dbTables.push(...(await this.query(tablesSql)))
+    dbTables.push(...(await this.query(tablesSql, parameters)))
 }
Suggestion importance[1-10]: 10

__

Why: The suggestion correctly identifies a critical SQL injection vulnerability in the loadTables method and provides a secure fix using parameterized queries, which is the standard best practice.

High
✅ Suggestions up to commit dfc7ce9
CategorySuggestion                                                                                                                                    Impact
General
✅ Remove redundant comment down query
Suggestion Impact:The suggestion was directly implemented. The commit removed the redundant downQuery block (lines 198-211) that was setting the column comment to NULL in the addColumn method, exactly as suggested.

code diff:

-        if (column.comment) {
-            upQueries.push(
-                new Query(
-                    `COMMENT ON COLUMN ${this.escapePath(table)}."${column.name}"
-                    IS ${this.escapeComment(column.comment)}`,
-                ),
-            )
-            downQueries.push(
-                new Query(
-                    `COMMENT ON COLUMN ${this.escapePath(table)}."${column.name}"
-                    IS NULL`,
-                ),
-            )
-        }

In the addColumn method, remove the redundant downQuery that sets the column
comment to NULL during a rollback, as the column itself is already being
dropped.

src/driver/sap/SapQueryRunner.ts [1114-1127]

 if (column.comment) {
     upQueries.push(
         new Query(
             `COMMENT ON COLUMN ${this.escapePath(table)}."${column.name}"
             IS ${this.escapeComment(column.comment)}`,
         ),
     )
-    downQueries.push(
-        new Query(
-            `COMMENT ON COLUMN ${this.escapePath(table)}."${column.name}"
-            IS NULL`,
-        ),
-    )
 }
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly identifies that the downQuery to nullify the column comment is redundant, as the main downQuery for addColumn already drops the entire column, making this a good logic simplification.

Low
✅ Suggestions up to commit e86e3e2
CategorySuggestion                                                                                                                                    Impact
General
✅ Remove redundant column comment cleanup
Suggestion Impact:The suggestion was implemented. The commit removed the redundant if (column.comment) block that was setting column comments to NULL in downQueries within the addColumn method (lines 198-211). This matches the suggestion's intent to eliminate redundant cleanup code since the column is already being dropped during rollback.

code diff:

-        if (column.comment) {
-            upQueries.push(
-                new Query(
-                    `COMMENT ON COLUMN ${this.escapePath(table)}."${column.name}"
-                    IS ${this.escapeComment(column.comment)}`,
-                ),
-            )
-            downQueries.push(
-                new Query(
-                    `COMMENT ON COLUMN ${this.escapePath(table)}."${column.name}"
-                    IS NULL`,
-                ),
-            )
-        }

In SapQueryRunner.ts, remove the redundant downQuery that sets a column's
comment to NULL within the addColumn method, as the column is already being
dropped on rollback.

src/driver/sap/SapQueryRunner.ts [1114-1127]

-if (column.comment) {
-    upQueries.push(
-        new Query(
-            `COMMENT ON COLUMN ${this.escapePath(table)}."${column.name}"
-            IS ${this.escapeComment(column.comment)}`,
-        ),
-    )
-    downQueries.push(
-        new Query(
-            `COMMENT ON COLUMN ${this.escapePath(table)}."${column.name}"
-            IS NULL`,
-        ),
-    )
-}
+// Remove this block - column comments are cleaned up when the column is dropped
Suggestion importance[1-10]: 5

__

Why: The suggestion correctly identifies that setting a column's comment to NULL in a downQuery is redundant if the column itself is already being dropped in another downQuery for the same operation. However, it incorrectly suggests removing the entire if (column.comment) block, which would also remove the necessary upQuery for adding the comment.

Low
✅ Suggestions up to commit bcb508f
CategorySuggestion                                                                                                                                    Impact
Security
✅ Fix SQL injection and incorrect logic
Suggestion Impact:The commit implemented the core suggestion by replacing string interpolation with parameterized queries across all three database types (SAP HANA, PostgreSQL, MySQL/MariaDB). The commit also removed the toUpperCase() call as suggested. Additionally, the commit added extra improvements not in the suggestion: added schema filtering for SAP HANA, and added null-safety checks for all database types to handle empty result sets.

code diff:

                 const res = await dataSource.query(
-                    `SELECT "COMMENTS" FROM "SYS"."TABLES" WHERE "TABLE_NAME" = '${tableName.toUpperCase()}'`,
+                    `SELECT "COMMENTS" FROM "SYS"."TABLES" WHERE "TABLE_NAME" = ? AND "SCHEMA_NAME" = 'SYSTEM'`,
+                    [tableName],
                 )
-                return res[0]["COMMENTS"]
+                return res.length > 0 ? res[0]["COMMENTS"] : undefined
             } else if (dbType === "postgres") {
                 const res = await dataSource.query(
-                    `SELECT obj_description('${tableName}'::regclass, 'pg_class') AS "comment"`,
+                    `SELECT obj_description($1::regclass, 'pg_class') AS "comment"`,
+                    [tableName],
                 )
-                return res[0]["comment"]
+                return res.length > 0 ? res[0]["comment"] : undefined
             } else if (dbType === "mysql" || dbType === "mariadb") {
                 const res = await dataSource.query(
-                    `SELECT \`TABLE_COMMENT\` FROM \`INFORMATION_SCHEMA\`.\`TABLES\` WHERE TABLE_NAME = "${tableName}"`,
+                    `SELECT \`TABLE_COMMENT\` FROM \`INFORMATION_SCHEMA\`.\`TABLES\` WHERE TABLE_NAME = ?`,
+                    [tableName],
                 )
-                return res[0]["TABLE_COMMENT"]
+                return res.length > 0 ? res[0]["TABLE_COMMENT"] : undefined

Refactor the loadCommentFromDB test helper to use parameterized queries instead
of string interpolation to prevent SQL injection, and remove the incorrect
toUpperCase() call for SAP HANA table names.

test/functional/query-runner/create-comment.test.ts [25-47]

 async function loadCommentFromDB(
     dataSource: DataSource,
     tableName: string,
 ) {
     const dbType = dataSource.driver.options.type
     if (dbType === "sap") {
         const res = await dataSource.query(
-            `SELECT "COMMENTS" FROM "SYS"."TABLES" WHERE "TABLE_NAME" = '${tableName.toUpperCase()}'`,
+            `SELECT "COMMENTS" FROM "SYS"."TABLES" WHERE "TABLE_NAME" = ?`,
+            [tableName],
         )
         return res[0]["COMMENTS"]
     } else if (dbType === "postgres") {
         const res = await dataSource.query(
-            `SELECT obj_description('${tableName}'::regclass, 'pg_class') AS "comment"`,
+            `SELECT obj_description($1::regclass, 'pg_class') AS "comment"`,
+            [tableName],
         )
         return res[0]["comment"]
     } else if (dbType === "mysql" || dbType === "mariadb") {
         const res = await dataSource.query(
-            `SELECT \`TABLE_COMMENT\` FROM \`INFORMATION_SCHEMA\`.\`TABLES\` WHERE TABLE_NAME = "${tableName}"`,
+            `SELECT \`TABLE_COMMENT\` FROM \`INFORMATION_SCHEMA\`.\`TABLES\` WHERE TABLE_NAME = ?`,
+            [tableName],
         )
         return res[0]["TABLE_COMMENT"]
     }
     return undefined
 }

[Suggestion processed]

Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies a potential SQL injection vulnerability and a logic bug (toUpperCase()) in the test helper function, improving test robustness and security best practices.

Medium
Possible issue
✅ Handle empty string comments correctly
Suggestion Impact:The suggestion was directly implemented in the commit. The escapeComment function was modified to check for empty strings (comment.length === 0) in addition to the existing falsy check, exactly as suggested.

code diff:

-        if (!comment) {
+        if (!comment || comment.length === 0) {

Update the escapeComment function for the SAP driver to handle empty strings by
returning NULL, ensuring consistent behavior for both undefined and empty string
comments.

src/driver/sap/SapQueryRunner.ts [3374-3382]

 protected escapeComment(comment?: string) {
-    if (!comment) {
+    if (!comment || comment.length === 0) {
         return "NULL"
     }
 
     comment = comment.replace(/'/g, "''").replace(/\u0000/g, "") // Null bytes aren't allowed in comments
 
     return `'${comment}'`
 }
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that an empty string comment for SAP HANA should be treated as NULL, and proposes a fix to escapeComment that makes the behavior consistent and correct.

Medium
General
Correct assertion for removed table comments

Correct the test assertion for a removed table comment to expect null instead of
oneOf([null, ""]), as all relevant drivers should return null.

test/functional/query-runner/create-comment.test.ts [97-102]

 const res2 = await loadCommentFromDB(
     connection,
     tableMetadata.tableName,
 )
 
-expect(res2).to.be.oneOf([null, ""])
+expect(res2).to.be.null
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that after removing a comment, the expected result should be null across all tested drivers, making the test assertion more precise and accurate.

Low

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jan 22, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (4) 📎 Requirement gaps (0)

Grey Divider


Action required

1. SQL Injection in MySQL createTableSql 🐞 Bug ⛨ Security
Description
• The MySQL driver's createTableSql method directly concatenates table.comment into SQL without
proper escaping, creating a SQL injection vulnerability • This is a pre-existing issue not
introduced by this PR, but it's inconsistent with the improved comment handling added in this PR •
Comments containing quotes, backslashes, or null bytes could break the SQL syntax or enable SQL
injection attacks • The escapeComment method exists and is used correctly in changeTableComment
(line 765-779 in the PR), but not in createTableSql (line 3120)
Code

src/driver/mysql/MysqlQueryRunner.ts[R765-779]

+        const escapedNewComment = this.escapeComment(newComment)
+        const escapedComment = this.escapeComment(table.comment)

-        if (newComment === comment) {
+        if (escapedNewComment === escapedComment) {
           return
       }

       const newTable = table.clone()
+        newTable.comment = newComment

       upQueries.push(
           new Query(
               `ALTER TABLE ${this.escapePath(
                   newTable,
-                )} COMMENT ${newComment}`,
+                )} COMMENT ${escapedNewComment}`,
Evidence
The PR improves comment handling in changeTableComment by using escapeComment, but the pre-existing
createTableSql method at line 3120 still uses unescaped table.comment. This creates an inconsistency
where ALTER TABLE operations are safe but CREATE TABLE operations are vulnerable. The escapeComment
method (line 3294-3305) properly handles backslashes, quotes, and null bytes, but it's not used in
createTableSql.

src/driver/mysql/MysqlQueryRunner.ts[3119-3121]
src/driver/mysql/MysqlQueryRunner.ts[3294-3305]
src/driver/mysql/MysqlQueryRunner.ts[765-779]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
# Issue Description
The MySQL driver's createTableSql method has a SQL injection vulnerability where table.comment is directly concatenated into the SQL string without proper escaping. This creates a security risk when creating tables with comments containing special characters.
# Issue Context
The PR improves comment handling in the changeTableComment method by using escapeComment, but the pre-existing createTableSql method still uses unescaped table.comment. The escapeComment method exists and properly handles backslashes, quotes, and null bytes, but it's not used in createTableSql.
The SAP driver's createTableSql (line 3188-3190) correctly uses escapeComment for table comments:

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


✅ 2. SAP Driver Missing Table Comment Creation 🐞 Bug ✓ Correctness
Description
• The SAP HANA driver does not create table comments during initial table creation via createTable
method • Table comments are only applied during schema synchronization, not when tables are first
created • This creates inconsistency with PostgreSQL and MySQL drivers which both add comments
during table creation • SAP HANA supports COMMENT ON TABLE syntax (proven by the implemented
changeTableComment method), but this capability is not utilized in createTable
Code

src/driver/sap/SapQueryRunner.ts[R611-612]

   async createTable(
       table: Table,
Evidence
The SAP driver's createTable method lacks the table comment creation logic that exists in PostgreSQL
driver. The changeTableComment implementation proves SAP HANA supports the COMMENT ON TABLE syntax,
but this is not used during table creation.

src/driver/postgres/PostgresQueryRunner.ts[628-640]
src/driver/sap/SapQueryRunner.ts[3554-3556]
src/driver/sap/SapQueryRunner.ts[611-649]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue Description
The SAP HANA driver's createTable method does not create table comments during initial table creation. While the changeTableComment method correctly implements COMMENT ON TABLE syntax for SAP HANA, this capability is not utilized when tables are first created.
## Issue Context
- SAP HANA supports COMMENT ON TABLE syntax (proven by changeTableComment implementation at lines 3554-3556)
- PostgreSQL driver correctly adds table comments during createTable (lines 628-640)
- MySQL driver adds comments inline in CREATE TABLE statement (line 3120)
- SAP driver only applies comments during schema synchronization, not initial creation
## Fix Focus Areas
- src/driver/sap/SapQueryRunner.ts[611-649] - Add table comment creation logic after indices handling, before executeQueries call

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


✅ 3. Documentation incomplete for table comments 📘 Rule violation ✓ Correctness
Description
• The PR adds support for table comments in SAP HANA, which is a user-facing feature. • The
documentation was updated only for column comments (line 147 in decorator-reference.md) but not for
the @Entity decorator's comment option. • The PR checklist explicitly shows documentation was
NOT completed (unchecked box).
Code

docs/docs/help/3-decorator-reference.md[147]

+-   `comment: string` - Database's column comment. Not supported by all database types. Supported databases: MySQL, MariaDB, PostgreSQL, SAP HANA.
Evidence
The compliance rule requires documentation updates for user-facing changes. The PR adds table
comment support (a user-facing feature) but only documents column comments. The @Entity decorator
reference (lines 19-24) does not list the comment option, and the PR description shows
documentation is incomplete (unchecked box in checklist).

Rule 2: Docs updated for user-facing changes
test/functional/query-runner/entity/Company.ts[3-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR adds support for table comments via the `@Entity({ comment: "..." })` option, but this option is not documented in the @Entity decorator reference section.
## Issue Context
The feature is user-facing and allows developers to add comments to database tables. The test file shows usage: `@Entity({ comment: "This is a company entity" })`. The decorator reference currently lists options like `name`, `database`, `schema`, `engine`, `synchronize`, and `orderBy` but omits `comment`.
## Fix Focus Areas
- docs/docs/help/3-decorator-reference.md[19-24]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
✅ 4. Table comment feature lacks documentation 📘 Rule violation ✓ Correctness
Description
• The PR introduces a new user-facing feature (table comments support for SAP HANA) but does not
update the documentation. • The @Entity decorator now supports a comment option, but this is not
documented in the decorator reference (docs/docs/help/3-decorator-reference.md). • Users will not be
able to discover or use this feature without proper documentation.
Code

test/functional/query-runner/entity/Company.ts[3]

+@Entity({ comment: "This is a company entity" })
Evidence
The PR introduces table comment support as a user-facing feature (adding comment option to @Entity
decorator), but the documentation has not been updated. The PR description explicitly shows
documentation was NOT checked off in the pull-request checklist. The decorator reference
documentation at docs/docs/help/3-decorator-reference.md lists @Entity options but does not include
the comment option, and the SAP driver documentation does not mention table comment support.

Rule 2: Docs updated for user-facing changes
test/functional/query-runner/entity/Company.ts[3-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR introduces support for table comments in SAP HANA (and fixes for Postgres/MySQL), but the documentation has not been updated to reflect this new user-facing feature.
## Issue Context
The `@Entity` decorator now accepts a `comment` option that allows users to add comments to database tables. This feature is now supported in SAP HANA, PostgreSQL, MySQL, and MariaDB drivers. Users need to know about this option to use it.
## Fix Focus Areas
- docs/docs/help/3-decorator-reference.md[18-24] - Add `comment` to the list of @Entity options
- docs/docs/drivers/sap.md[1-76] - Optionally add a section about table comment support

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

5. Test hardcodes SAP HANA schema as 'SYSTEM' 🐞 Bug ⛯ Reliability ⭐ New
Description
The loadCommentFromDB test helper hardcodes SCHEMA_NAME = 'SYSTEM' in its SAP HANA query. If
tests run against a SAP HANA instance where the test user has a different default schema, the query
returns no rows and comment assertions will fail with undefined.
Code

test/functional/query-runner/create-comment.test.ts[R31-36]

+            if (dbType === "sap") {
+                const res = await dataSource.query(
+                    `SELECT "COMMENTS" FROM "SYS"."TABLES" WHERE "TABLE_NAME" = ? AND "SCHEMA_NAME" = 'SYSTEM'`,
+                    [tableName],
+                )
+                return res.length > 0 ? res[0]["COMMENTS"] : undefined
Evidence
The production SapQueryRunner.loadTables resolves the schema dynamically via getCurrentSchema(),
but the test helper bypasses this and hardcodes 'SYSTEM'. This makes the test fragile for any
non-default SAP HANA configuration.

test/functional/query-runner/create-comment.test.ts[31-36]
src/driver/sap/SapQueryRunner.ts[2656-2657]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The `loadCommentFromDB` helper in the SAP HANA test branch hardcodes `SCHEMA_NAME = 'SYSTEM'`. This will silently return `undefined` when tests run against a SAP HANA instance where the test user has a different default schema, causing assertion failures.

## Issue Context
- The production code in `SapQueryRunner.loadTables` correctly resolves the schema dynamically via `getCurrentSchema()`.
- SAP HANA exposes the current schema via `SELECT CURRENT_SCHEMA FROM DUMMY`.

## Fix Focus Areas
- Replace the hardcoded schema filter with a dynamic schema lookup in the test helper:
 - test/functional/query-runner/create-comment.test.ts[31-36]

Example fix:
```typescript
if (dbType === "sap") {
   const schemaRes = await dataSource.query(`SELECT CURRENT_SCHEMA FROM DUMMY`)
   const schema = schemaRes[0]["CURRENT_SCHEMA"]
   const res = await dataSource.query(
       `SELECT "COMMENTS" FROM "SYS"."TABLES" WHERE "TABLE_NAME" = ? AND "SCHEMA_NAME" = ?`,
       [tableName, schema],
   )
   return res.length > 0 ? res[0]["COMMENTS"] : undefined
}
```

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Excessive JSDoc @PARAM tags added 📘 Rule violation ✓ Correctness
Description
• The PR adds numerous @param JSDoc tags to existing methods in SapQueryRunner.ts that previously
had only description comments without parameter documentation. • This pattern is inconsistent with
the existing codebase style where most methods have only description comments without @param tags
(e.g., lines 411-412, 443-444, 454-455, 478-479). • The added @param tags appear to be AI-generated
noise as they don't add meaningful documentation value and deviate from the established file
conventions.
Code

src/driver/sap/SapQueryRunner.ts[R106-109]

+     * @param isolationLevel
    */
   async startTransaction(isolationLevel?: IsolationLevel): Promise<void> {
       if (this.isReleased) throw new QueryRunnerAlreadyReleasedError()
Evidence
The compliance rule 'Remove AI-generated noise' requires that changes should not introduce AI-like
comments or style inconsistent with the file. The SapQueryRunner.ts file shows a clear pattern where
most methods have only description comments without @param tags (lines 411-412, 443-444, 454-455,
478-479 show methods with descriptions only). The PR adds @param tags to dozens of methods (lines
106, 173-174, 193-195, 336-339, 423, 435, 470, 490, 507-508, etc.), which is inconsistent with the
existing style. Similar query runner files like MysqlQueryRunner.ts and PostgresQueryRunner.ts also
follow the pattern of having description-only comments for most methods.

Rule 4: Remove AI-generated noise
src/driver/sap/SapQueryRunner.ts[410-412]
src/driver/sap/SapQueryRunner.ts[106-107]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR adds numerous @param JSDoc tags to existing methods in SapQueryRunner.ts, which is inconsistent with the established documentation style in the file. Most methods in this file and similar query runner files have only description comments without @param tags.
## Issue Context
The file follows a pattern where methods have concise description-only JSDoc comments. Adding @param tags to dozens of methods creates inconsistency and appears to be AI-generated noise that doesn&amp;#x27;t add meaningful documentation value.
## Fix Focus Areas
- src/driver/sap/SapQueryRunner.ts[106-106]
- src/driver/sap/SapQueryRunner.ts[173-174]
- src/driver/sap/SapQueryRunner.ts[193-195]
- src/driver/sap/SapQueryRunner.ts[336-339]
- src/driver/sap/SapQueryRunner.ts[423-423]
- src/driver/sap/SapQueryRunner.ts[435-435]
- src/driver/sap/SapQueryRunner.ts[470-470]
- src/driver/sap/SapQueryRunner.ts[490-490]
- src/driver/sap/SapQueryRunner.ts[507-508]
- src/driver/sap/SapQueryRunner.ts[528-529]
- src/driver/sap/SapQueryRunner.ts[540-541]
- src/driver/sap/SapQueryRunner.ts[549-550]
- src/driver/sap/SapQueryRunner.ts[577-579]
- src/driver/sap/SapQueryRunner.ts[606-609]
- src/driver/sap/SapQueryRunner.ts[653-656]
- src/driver/sap/SapQueryRunner.ts[702-703]
- src/driver/sap/SapQueryRunner.ts[722-722]
- src/driver/sap/SapQueryRunner.ts[739-740]
- src/driver/sap/SapQueryRunner.ts[949-950]
- src/driver/sap/SapQueryRunner.ts[1147-1148]
- src/driver/sap/SapQueryRunner.ts[1161-1163]
- src/driver/sap/SapQueryRunner.ts[1194-1196]
- src/driver/sap/SapQueryRunner.ts[1617-1618]
- src/driver/sap/SapQueryRunner.ts[1631-1632]
- src/driver/sap/SapQueryRunner.ts[1878-1879]
- src/driver/sap/SapQueryRunner.ts[1892-1893]
- src/driver/sap/SapQueryRunner.ts[1919-1920]
- src/driver/sap/SapQueryRunner.ts[2070-2070]
- src/driver/sap/SapQueryRunner.ts[2172-2173]
- src/driver/sap/SapQueryRunner.ts[2186-2187]
- src/driver/sap/SapQueryRunner.ts[2200-2201]
- src/driver/sap/SapQueryRunner.ts[2214-2215]
- src/driver/sap/SapQueryRunner.ts[2228-2229]
- src/driver/sap/SapQueryRunner.ts[2255-2256]
- src/driver/sap/SapQueryRunner.ts[2270-2271]
- src/driver/sap/SapQueryRunner.ts[2296-2297]
- src/driver/sap/SapQueryRunner.ts[2311-2312]
- src/driver/sap/SapQueryRunner.ts[2325-2326]
- src/driver/sap/SapQueryRunner.ts[2339-2340]
- src/driver/sap/SapQueryRunner.ts[2353-2354]
- src/driver/sap/SapQueryRunner.ts[2367-2368]
- src/driver/sap/SapQueryRunner.ts[2395-2396]
- src/driver/sap/SapQueryRunner.ts[2410-2411]
- src/driver/sap/SapQueryRunner.ts[2445-2446]
- src/driver/sap/SapQueryRunner.ts[2460-2461]
- src/driver/sap/SapQueryRunner.ts[2482-2483]
- src/driver/sap/SapQueryRunner.ts[2497-2498]
- src/driver/sap/SapQueryRunner.ts[2526-2527]
- src/driver/sap/SapQueryRunner.ts[2542-2542]
- src/driver/sap/SapQueryRunner.ts[2650-2650]
- src/driver/sap/SapQueryRunner.ts[3049-3050]
- src/driver/sap/SapQueryRunner.ts[3197-3198]
- src/driver/sap/SapQueryRunner.ts[3245-3245]
- src/driver/sap/SapQueryRunner.ts[3253-3253]
- src/driver/sap/SapQueryRunner.ts[3283-3284]
- src/driver/sap/SapQueryRunner.ts[3307-3308]
- src/driver/sap/SapQueryRunner.ts[3330-3331]
- src/driver/sap/SapQueryRunner.ts[3350-3350]
- src/driver/sap/SapQueryRunner.ts[3367-3368]
- src/driver/sap/SapQueryRunner.ts[3383-3384]
- src/driver/sap/SapQueryRunner.ts[3402-3403]
- src/driver/sap/SapQueryRunner.ts[3448-3449]
- src/driver/sap/SapQueryRunner.ts[3469-3469]
- src/driver/sap/SapQueryRunner.ts[3483-3483]
- src/driver/sap/SapQueryRunner.ts[3497-3499]
- src/driver/sap/SapQueryRunner.ts[3533-3534]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


✅ 7. Test missing issue reference comment 📘 Rule violation ✓ Correctness
Description
• The functional test does not include a reference to issue #10621 in a comment. • Compliance rule 3
requires issue references in test comments when applicable. • While the test is correctly placed in
test/functional, it should include a comment referencing the issue for traceability.
Code

test/functional/query-runner/create-comment.test.ts[R10-11]

+describe("create comment", () => {
+    describe("table comment", () => {
Evidence
The compliance rule states that issue fixes should add or update tests in test/functional with an
issue reference in the test comment when applicable. The test is correctly placed in
test/functional, but lacks a comment referencing issue #10621. Other functional tests in the
codebase include issue references (e.g., '// GitHub issue #7738', '// Github issue #5321').

Rule 3: Prefer functional tests over per-issue tests
test/functional/query-runner/create-comment.test.ts[10-11]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The functional test for table comments should include a reference to the GitHub issue it addresses for better traceability.
## Issue Context
This test was added to fix issue #10621. Following the project&amp;#x27;s pattern of including issue references in test comments, a comment should be added.
## Fix Focus Areas
- test/functional/query-runner/create-comment.test.ts[10-10] - Add comment like &amp;#x27;// GitHub issue #10621&amp;#x27; before the describe block

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Grey Divider

Previous review results

Review updated until commit 49fd096

Results up to commit 1194007


🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0)

Grey Divider
Action required
1. SQL Injection in MySQL createTableSql 🐞 Bug ⛨ Security
Description
• The MySQL driver's createTableSql method directly concatenates table.comment into SQL without
  proper escaping, creating a SQL injection vulnerability
• This is a pre-existing issue not introduced by this PR, but it's inconsistent with the improved
  comment handling added in this PR
• Comments containing quotes, backslashes, or null bytes could break the SQL syntax or enable SQL
  injection attacks
• The escapeComment method exists and is used correctly in changeTableComment (line 765-779 in the
  PR), but not in createTableSql (line 3120)
Code

src/driver/mysql/MysqlQueryRunner.ts[R765-779]

+        const escapedNewComment = this.escapeComment(newComment)
+        const escapedComment = this.escapeComment(table.comment)

-        if (newComment === comment) {
+        if (escapedNewComment === escapedComment) {
            return
        }

        const newTable = table.clone()
+        newTable.comment = newComment

        upQueries.push(
            new Query(
                `ALTER TABLE ${this.escapePath(
                    newTable,
-                )} COMMENT ${newComment}`,
+                )} COMMENT ${escapedNewComment}`,
Evidence
The PR improves comment handling in changeTableComment by using escapeComment, but the pre-existing
createTableSql method at line 3120 still uses unescaped table.comment. This creates an inconsistency
where ALTER TABLE operations are safe but CREATE TABLE operations are vulnerable. The escapeComment
method (line 3294-3305) properly handles backslashes, quotes, and null bytes, but it's not used in
createTableSql.

src/driver/mysql/MysqlQueryRunner.ts[3119-3121]
src/driver/mysql/MysqlQueryRunner.ts[3294-3305]
src/driver/mysql/MysqlQueryRunner.ts[765-779]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

# Issue Description
The MySQL driver&#x27;s createTableSql method has a SQL injection vulnerability where table.comment is directly concatenated into the SQL string without proper escaping. This creates a security risk when creating tables with comments containing special characters.

# Issue Context
The PR improves comment handling in the changeTableComment method by using escapeComment, but the pre-existing createTableSql method still uses unescaped table.comment. The escapeComment method exists and properly handles backslashes, quotes, and null bytes, but it&#x27;s not used in createTableSql.

The SAP driver&#x27;s createTableSql (line 3188-3190) correctly uses escapeComment for table comments:
```typescript
if (table.comment) {
   sql += ` COMMENT ${this.escapeComment(table.comment)}`
}
```

# Fix Focus Areas
- src/driver/mysql/MysqlQueryRunner.ts[3119-3121]

Change from:
```typescript
if (table.comment) {
   sql += ` COMMENT=&quot;${table.comment}&quot;`
}
```

To:
```typescript
if (table.comment) {
   sql += ` COMMENT=${this.escapeComment(table.comment)}`
}
```

Note: Remove the double quotes around the comment value since escapeComment already adds the necessary quotes.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
2. Excessive JSDoc @PARAM tags added 📘 Rule violation ✓ Correctness
Description
• The PR adds numerous @param JSDoc tags to existing methods in SapQueryRunner.ts that previously
  had only description comments without parameter documentation.
• This pattern is inconsistent with the existing codebase style where most methods have only
  description comments without @param tags (e.g., lines 411-412, 443-444, 454-455, 478-479).
• The added @param tags appear to be AI-generated noise as they don't add meaningful documentation
  value and deviate from the established file conventions.
Code

src/driver/sap/SapQueryRunner.ts[R106-109]

+     * @param isolationLevel
     */
    async startTransaction(isolationLevel?: IsolationLevel): Promise<void> {
        if (this.isReleased) throw new QueryRunnerAlreadyReleasedError()
Evidence
The compliance rule 'Remove AI-generated noise' requires that changes should not introduce AI-like
comments or style inconsistent with the file. The SapQueryRunner.ts file shows a clear pattern where
most methods have only description comments without @param tags (lines 411-412, 443-444, 454-455,
478-479 show methods with descriptions only). The PR adds @param tags to dozens of methods (lines
106, 173-174, 193-195, 336-339, 423, 435, 470, 490, 507-508, etc.), which is inconsistent with the
existing style. Similar query runner files like MysqlQueryRunner.ts and PostgresQueryRunner.ts also
follow the pattern of having description-only comments for most methods.

Rule 4: Remove AI-generated noise
src/driver/sap/SapQueryRunner.ts[410-412]
src/driver/sap/SapQueryRunner.ts[106-107]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR adds numerous @param JSDoc tags to existing methods in SapQueryRunner.ts, which is inconsistent with the established documentation style in the file. Most methods in this file and similar query runner files have only description comments without @param tags.

## Issue Context
The file follows a pattern where methods have concise description-only JSDoc comments. Adding @param tags to dozens of methods creates inconsistency and appears to be AI-generated noise that doesn&#x27;t add meaningful documentation value.

## Fix Focus Areas
- src/driver/sap/SapQueryRunner.ts[106-106]
- src/driver/sap/SapQueryRunner.ts[173-174]
- src/driver/sap/SapQueryRunner.ts[193-195]
- src/driver/sap/SapQueryRunner.ts[336-339]
- src/driver/sap/SapQueryRunner.ts[423-423]
- src/driver/sap/SapQueryRunner.ts[435-435]
- src/driver/sap/SapQueryRunner.ts[470-470]
- src/driver/sap/SapQueryRunner.ts[490-490]
- src/driver/sap/SapQueryRunner.ts[507-508]
- src/driver/sap/SapQueryRunner.ts[528-529]
- src/driver/sap/SapQueryRunner.ts[540-541]
- src/driver/sap/SapQueryRunner.ts[549-550]
- src/driver/sap/SapQueryRunner.ts[577-579]
- src/driver/sap/SapQueryRunner.ts[606-609]
- src/driver/sap/SapQueryRunner.ts[653-656]
- src/driver/sap/SapQueryRunner.ts[702-703]
- src/driver/sap/SapQueryRunner.ts[722-722]
- src/driver/sap/SapQueryRunner.ts[739-740]
- src/driver/sap/SapQueryRunner.ts[949-950]
- src/driver/sap/SapQueryRunner.ts[1147-1148]
- src/driver/sap/SapQueryRunner.ts[1161-1163]
- src/driver/sap/SapQueryRunner.ts[1194-1196]
- src/driver/sap/SapQueryRunner.ts[1617-1618]
- src/driver/sap/SapQueryRunner.ts[1631-1632]
- src/driver/sap/SapQueryRunner.ts[1878-1879]
- src/driver/sap/SapQueryRunner.ts[1892-1893]
- src/driver/sap/SapQueryRunner.ts[1919-1920]
- src/driver/sap/SapQueryRunner.ts[2070-2070]
- src/driver/sap/SapQueryRunner.ts[2172-2173]
- src/driver/sap/SapQueryRunner.ts[2186-2187]
- src/driver/sap/SapQueryRunner.ts[2200-2201]
- src/driver/sap/SapQueryRunner.ts[2214-2215]
- src/driver/sap/SapQueryRunner.ts[2228-2229]
- src/driver/sap/SapQueryRunner.ts[2255-2256]
- src/driver/sap/SapQueryRunner.ts[2270-2271]
- src/driver/sap/SapQueryRunner.ts[2296-2297]
- src/driver/sap/SapQueryRunner.ts[2311-2312]
- src/driver/sap/SapQueryRunner.ts[2325-2326]
- src/driver/sap/SapQueryRunner.ts[2339-2340]
- src/driver/sap/SapQueryRunner.ts[2353-2354]
- src/driver/sap/SapQueryRunner.ts[2367-2368]
- src/driver/sap/SapQueryRunner.ts[2395-2396]
- src/driver/sap/SapQueryRunner.ts[2410-2411]
- src/driver/sap/SapQueryRunner.ts[2445-2446]
- src/driver/sap/SapQueryRunner.ts[2460-2461]
- src/driver/sap/SapQueryRunner.ts[2482-2483]
- src/driver/sap/SapQueryRunner.ts[2497-2498]
- src/driver/sap/SapQueryRunner.ts[2526-2527]
- src/driver/sap/SapQueryRunner.ts[2542-2542]
- src/driver/sap/SapQueryRunner.ts[2650-2650]
- src/driver/sap/SapQueryRunner.ts[3049-3050]
- src/driver/sap/SapQueryRunner.ts[3197-3198]
- src/driver/sap/SapQueryRunner.ts[3245-3245]
- src/driver/sap/SapQueryRunner.ts[3253-3253]
- src/driver/sap/SapQueryRunner.ts[3283-3284]
- src/driver/sap/SapQueryRunner.ts[3307-3308]
- src/driver/sap/SapQueryRunner.ts[3330-3331]
- src/driver/sap/SapQueryRunner.ts[3350-3350]
- src/driver/sap/SapQueryRunner.ts[3367-3368]
- src/driver/sap/SapQueryRunner.ts[3383-3384]
- src/driver/sap/SapQueryRunner.ts[3402-3403]
- src/driver/sap/SapQueryRunner.ts[3448-3449]
- src/driver/sap/SapQueryRunner.ts[3469-3469]
- src/driver/sap/SapQueryRunner.ts[3483-3483]
- src/driver/sap/SapQueryRunner.ts[3497-3499]
- src/driver/sap/SapQueryRunner.ts[3533-3534]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



ⓘ The new review experience is currently in Beta. Learn more

Results up to commit 70bd716


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
Results up to commit 7201a08


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider
Action required
✅ 1. SAP Driver Missing Table Comment Creation 🐞 Bug ✓ Correctness
Suggestion Impact:The commit implemented the suggestion by adding table comment support directly in the CREATE TABLE statement (lines 508-510). Instead of using a separate COMMENT ON TABLE query after table creation as suggested, the implementation adds the comment inline using COMMENT syntax within the CREATE TABLE SQL statement, which is a valid and more efficient approach for SAP HANA.

code diff:

@@ -3112,11 +3185,17 @@
 
         sql += `)`
 
+        if (table.comment) {
+            sql += ` COMMENT ${this.escapeComment(table.comment)}`
+        }
+
         return new Query(sql)

Description
• The SAP HANA driver does not create table comments during initial table creation via createTable
  method
• Table comments are only applied during schema synchronization, not when tables are first created
• This creates inconsistency with PostgreSQL and MySQL drivers which both add comments during table
  creation
• SAP HANA supports COMMENT ON TABLE syntax (proven by the implemented changeTableComment method),
  but this capability is not utilized in createTable
Code

src/driver/sap/SapQueryRunner.ts[R611-612]

    async createTable(
        table: Table,
Evidence
The SAP driver's createTable method lacks the table comment creation logic that exists in PostgreSQL
driver. The changeTableComment implementation proves SAP HANA supports the COMMENT ON TABLE syntax,
but this is not used during table creation.

src/driver/postgres/PostgresQueryRunner.ts[628-640]
src/driver/sap/SapQueryRunner.ts[3554-3556]
src/driver/sap/SapQueryRunner.ts[611-649]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue Description
The SAP HANA driver&#x27;s createTable method does not create table comments during initial table creation. While the changeTableComment method correctly implements COMMENT ON TABLE syntax for SAP HANA, this capability is not utilized when tables are first created.

## Issue Context
- SAP HANA supports COMMENT ON TABLE syntax (proven by changeTableComment implementation at lines 3554-3556)
- PostgreSQL driver correctly adds table comments during createTable (lines 628-640)
- MySQL driver adds comments inline in CREATE TABLE statement (line 3120)
- SAP driver only applies comments during schema synchronization, not initial creation

## Fix Focus Areas
- src/driver/sap/SapQueryRunner.ts[611-649] - Add table comment creation logic after indices handling, before executeQueries call

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit dfc7ce9


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review
Results up to commit e2ffb22


🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0)

Grey Divider
Action required
✅ 1. Documentation incomplete for table comments 📘 Rule violation ✓ Correctness
Suggestion Impact:The commit directly implements the suggestion by adding documentation for the comment option in the @entity decorator reference section (line 6) and including a usage example in the code sample (line 14). This addresses the incomplete documentation issue raised in the suggestion.

code diff:

+- `comment` - Database table comment. Not supported by all database types. Currently supported by MySQL, MariaDB, PostgreSQL, SAP HANA.
 - `engine` - database engine to be set during table creation (works only in some databases).
 - `synchronize` - entities marked with `false` are skipped from schema updates.
 - `orderBy` - specifies default ordering for entities when using `find` operations and `QueryBuilder`.
@@ -31,6 +32,7 @@
     engine: "MyISAM",
     database: "example_dev",
     schema: "schema_with_best_tables",
+    comment: "This is users table",

Description
• The PR adds support for table comments in SAP HANA, which is a user-facing feature.
• The documentation was updated only for column comments (line 147 in decorator-reference.md) but
  not for the @Entity decorator's comment option.
• The PR checklist explicitly shows documentation was NOT completed (unchecked box).
Code

docs/docs/help/3-decorator-reference.md[147]

+-   `comment: string` - Database's column comment. Not supported by all database types. Supported databases: MySQL, MariaDB, PostgreSQL, SAP HANA.
Evidence
The compliance rule requires documentation updates for user-facing changes. The PR adds table
comment support (a user-facing feature) but only documents column comments. The @Entity decorator
reference (lines 19-24) does not list the comment option, and the PR description shows
documentation is incomplete (unchecked box in checklist).

Rule 2: Docs updated for user-facing changes
test/functional/query-runner/entity/Company.ts[3-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR adds support for table comments via the `@Entity({ comment: &quot;...&quot; })` option, but this option is not documented in the @Entity decorator reference section.

## Issue Context
The feature is user-facing and allows developers to add comments to database tables. The test file shows usage: `@Entity({ comment: &quot;This is a company entity&quot; })`. The decorator reference currently lists options like `name`, `database`, `schema`, `engine`, `synchronize`, and `orderBy` but omits `comment`.

## Fix Focus Areas
- docs/docs/help/3-decorator-reference.md[19-24]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit bcb508f


🐞 Bugs (0) 📘 Rule violations (2) 📎 Requirement gaps (0)

Grey Divider
Action required
✅ 1. Table comment feature lacks documentation 📘 Rule violation ✓ Correctness
Suggestion Impact:The commit directly implements the suggestion by adding documentation for the 'comment' option in the @entity decorator reference. It adds the option to the list with a description of supported databases (MySQL, MariaDB, PostgreSQL, SAP HANA) and includes an example usage in the code sample.

code diff:

@@ -19,6 +19,7 @@
 - `name` - table name. If not specified, then table name is generated from entity class name.
 - `database` - database name in selected DB server.
 - `schema` - schema name.
+- `comment` - Database table comment. Not supported by all database types. Currently supported by MySQL, MariaDB, PostgreSQL, SAP HANA.
 - `engine` - database engine to be set during table creation (works only in some databases).
 - `synchronize` - entities marked with `false` are skipped from schema updates.
 - `orderBy` - specifies default ordering for entities when using `find` operations and `QueryBuilder`.
@@ -31,6 +32,7 @@
     engine: "MyISAM",
     database: "example_dev",
     schema: "schema_with_best_tables",
+    comment: "This is users table",
     synchronize: false,
     orderBy: {
         name: "ASC",

Description
• The PR introduces a new user-facing feature (table comments support for SAP HANA) but does not
  update the documentation.
• The @Entity decorator now supports a comment option, but this is not documented in the
  decorator reference (docs/docs/help/3-decorator-reference.md).
• Users will not be able to discover or use this feature without proper documentation.
Code

test/functional/query-runner/entity/Company.ts[3]

+@Entity({ comment: "This is a company entity" })
Evidence
The PR introduces table comment support as a user-facing feature (adding comment option to @Entity
decorator), but the documentation has not been updated. The PR description explicitly shows
documentation was NOT checked off in the pull-request checklist. The decorator reference
documentation at docs/docs/help/3-decorator-reference.md lists @Entity options but does not include
the comment option, and the SAP driver documentation does not mention table comment support.

Rule 2: Docs updated for user-facing changes
test/functional/query-runner/entity/Company.ts[3-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The PR introduces support for table comments in SAP HANA (and fixes for Postgres/MySQL), but the documentation has not been updated to reflect this new user-facing feature.

## Issue Context
The `@Entity` decorator now accepts a `comment` option that allows users to add comments to database tables. This feature is now supported in SAP HANA, PostgreSQL, MySQL, and MariaDB drivers. Users need to know about this option to use it.

## Fix Focus Areas
- docs/docs/help/3-decorator-reference.md[18-24] - Add `comment` to the list of @Entity options
- docs/docs/drivers/sap.md[1-76] - Optionally add a section about table comment support

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
✅ 2. Test missing issue reference comment 📘 Rule violation ✧ Quality
Suggestion Impact:The commit added the exact comment suggested: "// GitHub issue #10621 - Table comments not supported by typeorm for SAP HANA" at line 6, right before the "table comment" describe block.

code diff:

+    // GitHub issue #10621 - Table comments not supported by typeorm for SAP HANA

Description
• The functional test does not include a reference to issue #10621 in a comment.
• Compliance rule 3 requires issue references in test comments when applicable.
• While the test is correctly placed in test/functional, it should include a comment referencing the
  issue for traceability.
Code

test/functional/query-runner/create-comment.test.ts[R10-11]

+describe("create comment", () => {
+    describe("table comment", () => {
Evidence
The compliance rule states that issue fixes should add or update tests in test/functional with an
issue reference in the test comment when applicable. The test is correctly placed in
test/functional, but lacks a comment referencing issue #10621. Other functional tests in the
codebase include issue references (e.g., '// GitHub issue #7738', '// Github issue #5321').

Rule 3: Prefer functional tests over per-issue tests
test/functional/query-runner/create-comment.test.ts[10-11]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The functional test for table comments should include a reference to the GitHub issue it addresses for better traceability.

## Issue Context
This test was added to fix issue #10621. Following the project&#x27;s pattern of including issue references in test comments, a comment should be added.

## Fix Focus Areas
- test/functional/query-runner/create-comment.test.ts[10-10] - Add comment like &#x27;// GitHub issue #10621&#x27; before the describe block

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@Cprakhar
Cprakhar force-pushed the feat/table-comment-sap branch from e2ffb22 to e86e3e2 Compare January 22, 2026 20:07
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit e2ffb22

@Cprakhar
Cprakhar force-pushed the feat/table-comment-sap branch from e86e3e2 to dfc7ce9 Compare January 22, 2026 20:13
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit dfc7ce9

@coveralls

coveralls commented Jan 22, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 81.147% (+0.02%) from 81.125%
when pulling 1194007 on Cprakhar:feat/table-comment-sap
into 56137a1 on typeorm:master.

@alumni
alumni self-requested a review January 25, 2026 14:12
Comment thread src/driver/sap/SapQueryRunner.ts Resolved
Comment thread src/driver/sap/SapQueryRunner.ts Resolved
@Cprakhar
Cprakhar force-pushed the feat/table-comment-sap branch from dfc7ce9 to 7201a08 Compare January 26, 2026 14:37
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 7201a08

@Cprakhar
Cprakhar force-pushed the feat/table-comment-sap branch from 7201a08 to 70bd716 Compare January 26, 2026 15:01
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 70bd716

@Cprakhar
Cprakhar force-pushed the feat/table-comment-sap branch from 70bd716 to 1194007 Compare January 27, 2026 09:50
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 1194007

@gioboa
gioboa requested a review from alumni February 18, 2026 10:55

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your help @Cprakhar 🚀

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Persistent review updated to latest commit 49fd096

@gioboa
gioboa merged commit e71108f into typeorm:master Feb 18, 2026
39 checks passed
@pkuczynski pkuczynski added this to the 1.0 milestone Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Table comments for SAP HANA

5 participants