integresql icon indicating copy to clipboard operation
integresql copied to clipboard

Intrgresql returns non-existent database when long hash is used

Open Rudomitori opened this issue 11 months ago • 0 comments

If you try to initialize a template with a long hash, then integresql creates a database with a truncated name, but returns the database's name with the full hash

Example

Request:

curl --location 'http://127.0.0.1:5000/api/v1/templates' \
--header 'Content-Type: application/json' \
--data '{
    "hash": "very_long_hash_012345679-0123456789-0123456789-0123456789-0123456789-0123456789"
}'

Response:

{
    "database": {
        "templateHash": "very_long_hash_012345679-0123456789-0123456789-0123456789-0123456789-0123456789",
        "config": {
            "host": "postgres",
            "port": 5432,
            "username": "user",
            "password": "password",
            "database": "integresql_template_very_long_hash_012345679-0123456789-0123456789-0123456789-0123456789-0123456789"
        }
    }
}

The actual created database's name is integresql_template_very_long_hash_012345679-0123456789-0123456 instead of the returned integresql_template_very_long_hash_012345679-0123456789-0123456789-0123456789-0123456789-0123456789

Posible solution 1

Get an actual database's name from Postgresql right after the database is created, store it in db.DatabaseConfig and return it in the response

Posible solution 2

Add to the integresql's configs an option "max_database_name_lenght" with a default value of 63, and truncate hashes so, that a resulting template database's name and a test's one don't exceed the specified length

PostgreSQL version: 17.2 IntegreSQL's docker image: latest 5401184633aa

Rudomitori avatar Jan 19 '25 11:01 Rudomitori