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.
In this PR
CopyDatabase
function.newDBPool
towithDBPool
to ensure that resources are cleaned up appropriately.withTestDatabaseLocation
. This function is responsible for instantiating a test DB and destroying it after the tests have run, and provides theDatabaseLocation
of the freshly instantiated DB.InMemory Nothing
location is passed.Kupo.Data.Database.patternToSql
to take a function that escapes a binary literal, as the formats differ for SQLite and PostgreSQL.Problems
withTestDatabaseLocation
for Postgres is very flakey. Sometimes when the DB is dropped, an error occurs because another user (the Kupo process spun up by the test) is still using the DB. This leaves the test DB in tact which causes an error to be thrown on the next test run. I'm not sure why the test connection is not closed by the time the DB is dropped. My best guess is that it's becauselibpq
sometimes throws an error that "another command is already in progress", which seems to be ongoing issue withasync
usage ofpostgresql-simple
.Makefile
commands still do not work. As far as I can tell, there is no-iog-full
flavor ingithub:CardanoSolutions/devx
. The README does not mention this flavor and I verified withbuiltins.attrNames (builtins.getFlake github:CardanoSolutions/devx).outputs.devShells.x86_64-linux
.Work Remaining
TODOs
in areas that I think especially need review.DatabaseSpec
to work for both modules. Currently, those tests are "pending" in the PG version.Notes for future contributors
postgresql-simple
, parameters with data types likeText
,String
, and I think evenByteString
are wrapped in single quotes when inserted into the statement. Identifiers like column names or index names need to either be wrapped in theIdentifier
data type, which results in the parameter being wrapped in single quotes, or they need to be wrapped inPlain
which does not escape or wrap the parameter at all. I have chosen to useIdentifier
, but this means that the names are case-sensitive.