Skip to content

fix(plugins): view quoting, SQL injection, pagination, and misc SQL fixes - #1926

Closed
HandSonic wants to merge 6 commits into
OtterMind:mainfrom
HandSonic:fix/sql-plugins
Closed

fix(plugins): view quoting, SQL injection, pagination, and misc SQL fixes#1926
HandSonic wants to merge 6 commits into
OtterMind:mainfrom
HandSonic:fix/sql-plugins

Conversation

@HandSonic

Copy link
Copy Markdown
Contributor

Summary

Fixes 6 verified bugs across PostgreSQL, SQL Server, and Oracle database plugins.

Fixes included:

  • PostgreSQL view quoting: backticks → double quotes (PG syntax)
  • PostgreSQL view comment: added DOT separator between schema and view name
  • SQL Server view quoting: backticks → square brackets (SQL Server syntax)
  • Oracle view comment: added DOT separator between schema and view name
  • Oracle SQL injection: escapes single quotes in table name via replace("'", "''")
  • Oracle pagination: always applies outer SELECT wrapper to prevent CAHT2DB_AUTO_ROW_ID column leak on first page
  • SQL Server misc: fixes TIMESTAMP dead code (Arrays.asList()Arrays.asList("TIMESTAMP")), GO separator trailing newline, rename script bracket quoting

@openai0229 openai0229 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR combines six independent behavior changes across Oracle, PostgreSQL, and SQL Server without focused dialect tests. Please split it by dialect/behavior so each fix has a clear contract and regression coverage.

At minimum, the tests need to prove Oracle pagination with both bounds after the new wrapping behavior, real SQL Server sp_rename quoting syntax, SQL Server TIMESTAMP/rowversion DDL behavior, and view/comment quoting for each affected dialect. After splitting and testing, please update each branch with the current main.

@openai0229

Copy link
Copy Markdown
Contributor

Rechecked against current main. Two concrete blockers remain: Arrays.asList("TIMESTAMP").contains(type) compares a String list with a SqlServerColumnTypeEnum, so the supposedly enabled TIMESTAMP branch is still unreachable; and Oracle pagination now unconditionally appends both wrappers and both bounds, including zero-bound cases, without tests proving the generated SQL. Together with the unverified sp_rename syntax and cross-dialect quoting changes, this is not a small safe patch to merge as one unit. Please split by dialect/behavior and add the focused SQL assertions requested in the existing review.

…ent SQL

- View name was quoted with backticks (MySQL syntax) instead of double quotes
- Comment SQL was missing DOT separator between schema and view name,
  producing "schema""view" instead of "schema"."view"
View name was quoted with backticks (MySQL syntax) instead of square
brackets (SQL Server syntax).
View comment SQL was missing DOT between schema and view name identifiers,
producing "SCOTT""MY_VIEW" instead of "SCOTT"."MY_VIEW".
tableName was concatenated directly into SQL without escaping. Table names
containing single quotes (e.g. O'Brien) would break SQL syntax or allow
injection. Now escapes single quotes with replace("'", "''").
When offset==0 (first page), the outer SELECT * FROM (...) wrapper was
skipped, leaking CAHT2DB_AUTO_ROW_ID into the result set. Now both
wrappers are always applied for consistent column schema across pages.
- Arrays.asList() was empty, making TIMESTAMP precision block dead code.
  Now uses Arrays.asList('TIMESTAMP') to enable the code path.
- RENAME_COLUMN_SCRIPT parameters now use square bracket quoting for
  names with spaces or reserved words.
- COLUMN_MODIFY_COMMENT_SCRIPT now ends with 'go\n' (with trailing
  newline) so the batch separator is recognized when concatenated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants