Skip to content

fix: implement proper table name escaping for all DBMS#9

Open
vipitec-neo wants to merge 1 commit intohickelsoft:mainfrom
vipitec-neo:fix/sql-escape-tablename
Open

fix: implement proper table name escaping for all DBMS#9
vipitec-neo wants to merge 1 commit intohickelsoft:mainfrom
vipitec-neo:fix/sql-escape-tablename

Conversation

@vipitec-neo
Copy link

Problem

SQL_Escape_TableName had incomplete or incorrect escaping for most DBMS:

DBMS Before (broken) After (fixed) Source
SQL Server Escaped [ with [[] (wrong) Escape ] with ]] MS Docs
MySQL No backtick escaping ``` `` MySQL Docs
Firebird/InterBase Returned unquoted " quoting, """ Firebird Docs
Access Returned unquoted [] quoting, ]]] MS Docs
BDE/Local Returned unquoted [] quoting like Access

Tests

Unit Tests (Free Pascal)

11 tests covering all DBMS: simple names, special characters, schema-qualified names.

Integration Tests (Docker)

6 tests against real Firebird 4.0 and MariaDB 10:

  • Quoted identifiers with spaces ✅
  • Escaped special chars inside identifiers ✅
  • Unquoted names with spaces rejected ✅

Not testable in CI

  • InterBase: Proprietary, no Docker image. Same SQL dialect as Firebird.
  • Access: Windows-only (Jet/ACE engine).
  • BDE/Paradox/dBase: Legacy 32-bit only.

SQL_Escape_TableName had several issues:

1. SQL Server: escaped [ with [[] instead of escaping ] with ]].
   Only ] needs doubling inside [...] brackets.

2. MySQL: backticks in table names were not escaped.
   Fix: double backticks (`` -> ````).

3. InterBase/Firebird: table names were returned unquoted.
   Fix: use SQL-standard double-quote quoting ("" -> """").

4. Access: table names were returned unquoted.
   Fix: use square bracket quoting (] -> ]]).

5. BDE/Local: table names were returned unquoted.
   Fix: use square bracket quoting like Access.

Includes unit tests (Free Pascal) and integration tests against
real Firebird 4.0 and MariaDB 10 Docker containers.
@vipitec-neo vipitec-neo force-pushed the fix/sql-escape-tablename branch from 529d443 to 1ff40cb Compare February 10, 2026 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant