Skip to content

Reject UseBatchQueries on engines where batching is unverified #95

Description

@bero

TBoldSQLDataBaseConfig.UseBatchQueries concatenates the write statements of one UpdateDatabase into a single command (#80). Whether a server accepts several statements in one command - and parameters spread across them - is an engine property that the data-access layer does not abstract: SQL Server (TDS) does, SQLite via FireDAC does (verified), Oracle only inside a BEGIN … END; block (the config has the wrapper, unverified), Interbase/Firebird DSQL executes one statement per call, PostgreSQL's extended protocol allows one statement per parameterized command, MySQL needs a client flag. Only two engine branches in InitializeDbEngineSettings were ever written with batching in mind (dbeSQLServer tuning, dbeOracle wrapper).

Today nothing stops a user from enabling the flag on Firebird or PostgreSQL; the result is a save that fails at the server - or worse, partially applies - with an error that points at SQL syntax rather than at the setting.

Fix

  • TBoldSQLDataBaseConfig.BatchQueriesVerified: Engine in [dbeSQLServer, dbeGenericANSISQL92] - the engines the batch tests have run on (SQL Server, and SQLite which the test suite configures as generic ANSI SQL92).
  • TBoldBatchDataSetWrapper.StartSQLBatch: when UseBatchQueries is on for another engine, raise EBold naming the engine and the verified ones, before any statement is accumulated. The save fails at once with a message about the setting instead of a server error mid-batch.
  • The UseBatchQueries property comment lists the verified engines.

Verifying batching on another engine means running Test.BoldBatchQueries / Test.PersistenceScenarios* against it and adding it to the set.

Files changed

  • Source/PMapper/SQL/BoldSQLDatabaseConfig.pas
  • Source/Persistence/DB/BoldDBInterfaces.pas
  • Source/ObjectSpace/Core/BoldCoreConsts.pas (message)
  • UnitTest/Code/Persistence/Test.BoldBatchQueries.pas

Testing

  • RED: TestUnverifiedEngineIsRejected - Engine := dbePostgres on the live config with UseBatchQueries on, a save must raise a message naming UseBatchQueries and the engine; with the engine set back the same objects save normally
  • GREEN after the fix
  • Full suite green: 2179 found / 2177 passed / 2 ignored / 0 failed (FireDAC/SQLite); Test.PersistenceScenariosUniDAC 5/5 under DebugUniDAC on SQL Server (verified engine, guard silent)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions