Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Rudomitori opened this issue Jan 19, 2025 · 0 comments
Open

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

Rudomitori opened this issue Jan 19, 2025 · 0 comments

Comments

@Rudomitori
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant