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

Fix versatile regex #43

Open
CFarcy opened this issue Mar 4, 2022 · 0 comments
Open

Fix versatile regex #43

CFarcy opened this issue Mar 4, 2022 · 0 comments

Comments

@CFarcy
Copy link
Contributor

CFarcy commented Mar 4, 2022

On the PostgisSource model, the field db_host is using a custom regex as validator build with URLValidator

HOST_REGEX = (
    rf"(?:{URLValidator.ipv4_re}|{URLValidator.ipv6_re}|{URLValidator.host_re})"
)

If I understand correctly, this was made to validate URL withtout :// (which is mandatory in django URLValidator).

It create an issue with the regex being different between django version. As it is use directly as validator, it create diff in django migration when changing python version.

    db_host = models.CharField(
        max_length=255,
        validators=[RegexValidator(regex=HOST_REGEX)],
    )

In order to ensure stable behavior with multiple version of django, this part has been removed as a quick solution.
dd5b08a

One of the solution could be to create a CustomURLValidator from URLValidator and override the __call__ method to only validate the url and skip the scheme validation part.

cf: https://github.com/django/django/blob/main/django/core/validators.py#L117

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