FirebirdSQL / python3-driver

Firebird driver for Python that uses new Firebird API
https://www.firebirdsql.org/en/devel-python-driver/
MIT License
26 stars 10 forks source link

Suggestion: use Firebird embedded engines for tests? #22

Open fdcastel opened 1 year ago

fdcastel commented 1 year ago

What about to use Firebird embedded to test this project?

I have already collected all needed files here (for Windows). I'm using it to test Firebird dialect of SQLAlchemy against versions 2.5 through 5.0 of Firebird.

Also, the db tests could be generated from scratch, instead of being commited to this repository.

If agreed I'm available to submit PRs.

pcisar commented 1 year ago

Well, while I'm not against the idea, I'll insist that it must be an optional alternative, not the default one.

Generally, next month I'd like add support for FB5 to the driver, incl. tests, so I'll also add support for customization as outlined above.

fdcastel commented 1 year ago

Suggestions pushed to #23.

fdcastel commented 5 months ago

@pcisar I'm working again on this one and have already automated both environments for Linux and Windows.

Now I'm only missing the scripts to build fbtest30-src.fbk from scratch.

If you can provide them, I can submit a full PR to build everything from the ground up. Both on Linux and Windows.

pcisar commented 5 months ago

Well, you can use isql -x (or any other FB admin tool that can extract metadata as SQL) to get such script. Similarly it's possible to convert data stored in test database as SQL INSERTs. The sole problem is that isql is not able to work with ARRAY column values.

fdcastel commented 5 months ago

I believe this was exactly what I told you, half year ago, in #23.

That's why I'm asking you the source scripts.

pcisar commented 5 months ago

I know. But the ARRAY and to some extent BLOBs (text are easy since FB supports conversion from varchar or text literals, but binary or other sub types are still a problem) are the reason why test database was manually created and there is no SQL script to create it (it's that way since dawn of FDB time). AFAIK there is still no way around it. Of course, it could be handled by python script using the driver. Kind of weird approach to use driver to prepare test for driver, but they do it anyway to some extent in setup/teardown, so probably why not? But as the current mechanism works for me quite fine for years, I had no reason to spend time to do it.

fdcastel commented 5 months ago

Understood. But in this case HEX_ENCODE, HEX_DECODE and String Literals in Hex couldn't help?

They are a hell of inefficient (in space terms), but they are available in all versions. Base64 would be much better, but it was added only to Firebird 4.

I'll make some attempts in a few days.

pcisar commented 5 months ago

Well, those could probably help with binary BLOBs, but not with ARRAYs. I know that almost nobody uses them, but because driver supports them, there should be tests for them. These tests even helped to fix a regression in FB5 :) As I see it, the only possible solution to have test database created by some fixture/setup would be to give up to fill ARRAYs in SQL script, and change tests for ARRAYs so they would not require values already present in database. Guess that it would be also worth to rewrite all tests from unittest to pytest, but I don't have time for that.

fdcastel commented 5 months ago

These tests even helped to fix a regression in FB5 :)

Nice!

Guess that it would be also worth to rewrite all tests from unittest to pytest, but I don't have time for that.

If you are interested in this, I may get some days to work on it.

I have some experience with pytest working on SQLAlchemy Firebird dialect. It's a fantastic tool.