fix: make deploy_to_develop pipeline compatible with SQLite #2043
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What’s going on here?
The deploy_to_develop pipeline was failing when tests were run with SQLite. This PR fixes that so the pipeline works correctly regardless of the database backend.
What was breaking?
In scanpipe/pipes/d2d.py, the create_local_files_packages function was using ArrayAgg, which is specific to PostgreSQL. When running the pipeline with SQLite (commonly used for local development and CI), this caused the following error:
no such function: ARRAY_AGG
What did I change?
I updated the code to detect the database backend being used:
If the database is PostgreSQL, we keep using ArrayAgg
If it’s SQLite (or anything else), we fall back to grouping the data in Python instead
The result is the same, but now the pipeline doesn’t depend on PostgreSQL-only features.
How was this tested?
I ran the pipeline integration tests using SQLite, and everything passes as expected:
export SCANCODEIO_DB_ENGINE=django.db.backends.sqlite3
./manage.py test scanpipe.tests.test_pipelines