Skip to content

Intrgresql returns non-existent database when long hash is used #21

Open
@Rudomitori

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions