Skip to content

Database Modernization (insertOrIgnore, Upsert, Interfaces, PDO Db Capabilities [centralization], unit tests)#1088

Draft
belisoful wants to merge 53 commits intopradosoft:masterfrom
belisoful:db-modern-exec
Draft

Database Modernization (insertOrIgnore, Upsert, Interfaces, PDO Db Capabilities [centralization], unit tests)#1088
belisoful wants to merge 53 commits intopradosoft:masterfrom
belisoful:db-modern-exec

Conversation

@belisoful
Copy link
Copy Markdown
Member

@belisoful belisoful commented May 4, 2026

Here is the list of changes to Data:

  • TDbDriverCapabilities - centralized location of all Driver specific implementations.
    • Adds fxActiveRecordScaffoldInputClass for getting non-PDO driver classes.
    • Adds fxDataGetMetaDataClass for getting non-PDO driver classes.
  • Insert Or Ignore in Command Builder.
  • Upsert in Command Builder.
  • InsertOrIgnore and Upsert for ActiveRecord.
  • InsertOrIgnore and Upsert for SqlMap.
  • TDbDriver class to centralize the names of the PDO Drivers.
  • TDataCharset class to normalize Data Charsets.
  • Db Modules with PDO Driver Names updated to use TDbDriver for Driver Name.
  • Fixed processException in PradoUnit (a class for unit testing and suppressing multiple errors, eg Db connection).
    PradoUnit - [@todo - this feature should be abstracted to be key based and allow other unit tests to not repeat multiple of the same errors]
  • tweaks Github CI to remove pdo_firebird and pdo_sqlsrv from the main PHP CI matrix so those tests are skipped.
    (these are on by default. are they really so common?)
  • TDbTransaction::beginTransaction for "serial" transactions. Invalidated by TDbConnection::beginTransaction, which emits a new (replacement) TDbTransaction.
  • Lots of unit tests for classes in Data hierarchy.
  • Lots of unit tests for DbSpecific. Validation of each database system has exposed several bugs, all fixed.
  • Better class doc blocks for Data classes. This has been missing for far too long.
  • Adds TDbConnection methods:
    • commit/rollback. transactions are features of the connection; forwarded to the current transaction.
    • getLastTransaction. returns what is in the in the connection transaction property regardless of active. TDbTransaction::beginTransaction uses it to ensure that it is still the operational transaction for the connection; meaning, something else called TDbConnection::beginTransaction before the old transaction tried to beginTransaction.
    • __sleep => _getZappableSleepProps.
    • extractDriverFromDsn.
    • extractCharsetFromDsn.
    • applyCharsetToDsn.
    • getDatabaseCharset (gets the charset from database connection that it can be retrieved).
    • createTransaction (protected).
    • getHasAutoCommit.
    • assertActive.
  • Changed Mssql to SqlSrv to match the driver. "mssql" is not a PDO extension, it's a PHP extension. This is to make room for the possibility of implementing mssql PHP extension rather than just PDO.
  • TTableGateway::getTableExists to check for the existence of a table.

About 70% of this PR is unit tests.

Tested but removed:

  • a "TDbSerialTransaction" was tested, but conflated implicit transactions and explicit transactions making it simply an invalid ideation. I learned about the implicit and explicit state of transactions in PDO for AutoCommit, and, separately, of Firebird always being in a transaction on a connection. This was removed and replaced by TDbTransaction::beginTransaction.

Adds insertOrIgnore and upsert to: TActiveRecord, TDbCommandBuilder, TDataGatewayCommand, TTableGateway, and SqlMap.
TTableGateway adds getTableExists.
DbSpecific unit tests.
ActiveRecord, SqlMap, and TTableGateway::tableExists, DBSpecific unit tests
Adds TDbDriver to unify Driver Names with refactor.
TDbSerialTransaction renews transactions on rollback/commit.
TDataSourceConfig, TDbConnection, TDbSerialTransaction unit tests
TDataCharset
Parsing Charset from DSN when present, reverse map dbspecific charset to PRADO charset
Serial Transactions when AutoCommit is false
TDbConnection commit/rollback -> implemented by TDbTransaction
unit tests for charset and DbSpecific TDbDriverCapabilities unit tests
…tion to explicitly restart

driver specific unit tests of TDbDriverCapabilities.
sqlite command builder update
…n instance.

adds IScaffoldInput for custom class validation.
belisoful added 21 commits May 4, 2026 22:54
Conflicts:
	.github/workflows/prado.yml
	tests/unit/Data/TDbConnectionTest.php
	tests/unit/Data/TDbTransactionTest.php
…uring development

accidentally committed this.
…fic sql.

replaces mssql with SqlSvr in the doc blocks.
cleaned up the driver specific charsets.
…ugh Data

IDbConnection for PDO specific connections and IDataConnection for others.
Updated doc blocks
@belisoful belisoful force-pushed the db-modern-exec branch 3 times, most recently from 2bd2e4b to 6da956c Compare May 8, 2026 02:21
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