3YOURMIND / django-add-default-value

This django Migration Operation can be used to transfer a Fields default value to the database scheme.
Apache License 2.0
138 stars 19 forks source link

Warn when being run on non-supported database #29

Closed vanschelven closed 3 years ago

vanschelven commented 3 years ago

See #28

flixx commented 3 years ago

Hello @vanschelven, I've just tested your PR on our big django codebase.

It seems strange that the warning is only printed ONCE, although we use AddDefaultValue for many migrations...

So when executing ./manage.py migrate on a fresh sqllite database, I see this:

Applying b3_organization.0038_auto_20190603_0822... OK
/Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/django_add_default_value/add_default_value.py:77: UserWarning: AddDefaultValue cannot be applied on a non-supported vendor.
  warnings.warn(
  Applying b3_organization.0039_auto_20190701_0936... OK

But there are also tons of other migrations using AddDefaultValue as well that get executed as well without producing this warning...

Any idea what that is? / Can you reproduce?

If no, I would go ahead and merge your PR anyway over the next days. One warning is better then no warning ;)

Felix

vanschelven commented 3 years ago

From memory: this is probably the desired behavior for the "warnings " module which I've used: I suppose this feature allows one to put warnings at arbitrary positions in the code without worrying about spamming stderr.

I have to admit I didn't really forsee this, and picked this particular tool for warnings mostly because it was already used elsewhere in the code. If we see it as problematic enough to look for another solution I look into that, but it would probably necessitate some refactoring to have the required handle to stderr (via the management command) available at that point in the code.

On Fri, Feb 5, 2021, 18:21 Felix Bauer notifications@github.com wrote:

Hello @vanschelven https://github.com/vanschelven, I've just tested your PR on our big django codebase.

It seems strange that the warning is only printed ONCE, although we use AddDefaultValue for many migrations...

So when executing ./manage.py migrate on a fresh sqllite database, I see this:

Applying b3_organization.0038_auto_20190603_0822... OK /Users/felix/Library/Caches/pypoetry/virtualenvs/button3d-iF01JEUe-py3.8/lib/python3.8/site-packages/django_add_default_value/add_default_value.py:77: UserWarning: AddDefaultValue cannot be applied on a non-supported vendor. warnings.warn( Applying b3_organization.0039_auto_20190701_0936... OK

But there are also tons of other migrations using AddDefaultValue as well that get executed as well without producing this warning...

Any idea what that is?

If no, I would go ahead and merge your PR anyway over the next days. One warning is better then no warning ;)

Felix

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/3YOURMIND/django-add-default-value/pull/29#issuecomment-774170279, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABWUWME2UPDIANQ7DZSWCDS5QSKRANCNFSM4W5PNOCQ .[image: Web Bug from https://github.com/notifications/beacon/AABWUWNVIIYG3QLDA7S2EZTS5QSKRA5CNFSM4W5PNOC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFYSONJY.gif] [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": " https://github.com/3YOURMIND/django-add-default-value/pull/29#issuecomment-774170279", "url": " https://github.com/3YOURMIND/django-add-default-value/pull/29#issuecomment-774170279", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": " https://github.com" } } ]