-
Notifications
You must be signed in to change notification settings - Fork 77
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
Re-add database user and password as settings, and rename from MYSQL_* to SQL_* #258
Conversation
Codecov Report
@@ Coverage Diff @@
## main #258 +/- ##
==========================================
+ Coverage 98.57% 98.77% +0.20%
==========================================
Files 49 49
Lines 2175 2211 +36
Branches 304 310 +6
==========================================
+ Hits 2144 2184 +40
+ Misses 19 17 -2
+ Partials 12 10 -2
Continue to review full report at Codecov.
|
IMO we should just deprecate the MYSQL_ vars and make the breaking change. We'll want to do that before 1.0 in any case. If we want to be nice, we can detect |
I would prefer a proper deprecation cycle with a warning and then remove it in the next major version. Emitting this warning should be pretty painless. I suspect that we have a good amount of users by now (judging from the traffic and downstream projects), and I don't see any reason to break things unless we need to. |
In that case, @nickeopti ignore my approved review and let's add this warning. I was thinking that since we don't have DB migration yet, people would have to re-deploy when they upgrade in any case, so it's unlikely that this change would unexpectedly break an existing deployment. |
It was my understanding that DB migration is a hard requirement before the next release. |
Okay, I guess I thought that we would support DB migration from the next release and onwards and not from the current release to the next. |
I've implemented a deprecation system for the settings. Perhaps a bit over-engineered, but I think it does the job. One question, though, is whether we shall make the warnings more visible. Apparently the default settings in Python hide warnings.simplefilter('always', DeprecationWarning) There's also a question of I've not added tests for this yet. I'd like to know that the functionality is correct before adding those. |
I would have approached this a bit differently. Right now this seems weird to me: >>> settings = get_settings()
>>> settings.MYSQL_USER = "foo"
>>> settings.MYSQL_USER
AttributeError: 'TerracottaSettings' object has no attribute 'MYSQL_USER' I would suggest something simpler:
IMO Python's deprecation warnings are only appropriate for libraries, where you don't want end users to be bothered by them (i.e., where they are only relevant to developers). This is not the case in end-user applications and we should use a different warning that is visible by default. I suggest introducing a new warning class in |
But is that really a concern, as
That makes sense
I'll do that. Another question: |
Also, when setting a deprecated setting, eg
|
Right, my bad. It should have been
I'm not a big fan of introducing a dependency for functionality that is already present and works fine. IMO we have nothing to gain from switching at this point, but if others are positive to it I won't veto it :)
I'd go with number 2. |
I believe it is ready for review @dionhaefner |
Co-authored-by: Dion Häfner <[email protected]>
Co-authored-by: Dion Häfner <[email protected]>
Thanks @nickeopti ! |
The
SQLAlchemy
broke settingMYSQL_USER
andMYSQL_PASSWORD
settings. This PR fixes that.It also renames the fields from
MYSQL_*
to the more genericSQL_*
, in anticipation of the comingPostgreSQL
driver (and potential future others). This is currently just a plain rename, thus breaking compatibility with deployments using the previous fields. We need to decide whether that is okay, or whether there should be some deprecation warning system first.Ideally, we also ought to make some tests for this. I have apparently previously broken this, without noticing. That shouldn't be possible in the future. Feel free to just add such tests -- it may take a while before I'm back to do it.