pauldex / sqlalchemy-firebird

A Firebird dialect for SQLAlchemy using the firebird-driver and/or fdb python Firebird driver
MIT License
23 stars 15 forks source link

Revamp for SQLAlchemy 2.0 (was: SQLAlchemy test suite: Need for COMMIT between DDLs and DMLs) #46

Closed fdcastel closed 1 year ago

fdcastel commented 1 year ago

Currently many tests are failing because Firebird needs a COMMIT between a DDL which (for example) creates a table and a DML which inserts data in this table. Without this the insert will fail saying the table doesn't exists.

I did some attempts to overcome this using SQLAlchemy events infrastructure (after_create) to force a COMMIT/BEGIN TRANSACTION but it opened a larger can of worms. It worked for some tests but crashed several other ones.

Has anyone already worked on this problem? I'm asking for ideas/guidance before I dig into it more.

In contact with SQLAlchemy developers they have told me this was one of reasons it caused they to eject Firebird from core project (since no other database appears to have this requirement). So, I believe we are on our own, here.

pauldex commented 1 year ago

Thanks for this info. Perhaps we can update the fixtures used for setup/teardown to handle this problem.

fdcastel commented 1 year ago

I pushed my initial attempts to solve this problem here.

It seems promising:

======= 67 failed, 548 passed, 809 skipped, 9 errors in 16.67s ====

This is a work in progress. Please do not merge. I will submit a complete PR when all tests are passing.

fdcastel commented 1 year ago

I'm working on a full revamp of SQLAlchemy dialect. The current work can be seen in this branch.

The full test suite output currently is:

fdcastel commented 1 year ago

I've pushed my latest changes in this branch.

I'm running the tests against the three supported Firebird versions (2.5, 3.0 and 4.0). The test suite is in a much better state now 😄.

However, I just found some significant parts yet missing in the SQLAlchemy v2 architecture (e.g. autoincrement_column).

I'm now comparing the current code with the latest (official) PostgreSQL dialect for v2. It is being very helpful to find what is missing.

Also, there still are the problem with tests hanging in some cases when running the entire test suite (which doesn't occur when running the test isolated 😟)

fdcastel commented 1 year ago

Rebased with latest main.

fdcastel commented 1 year ago

All done in #48.