Merge remote-tracking branch 'proxy_login/1105-reverse-proxy-login'

Fix for creation of bool config settings (before: new bool columns where always created with true as default)
This commit is contained in:
Ozzieisaacs
2020-01-05 13:37:02 +01:00
5 changed files with 72 additions and 16 deletions

View File

@ -106,6 +106,9 @@ class _Settings(_Base):
config_updatechannel = Column(Integer, default=constants.UPDATE_STABLE)
config_reverse_proxy_login_header_name = Column(String)
config_allow_reverse_proxy_header_login = Column(Boolean, default=False)
def __repr__(self):
return self.__class__.__name__
@ -250,8 +253,7 @@ class _ConfigSQL(object):
for k, v in self.__dict__.items():
if k[0] == '_':
continue
if hasattr(s, k): # and getattr(s, k, None) != v:
# log.debug("_Settings save '%s' = %r", k, v)
if hasattr(s, k):
setattr(s, k, v)
log.debug("_ConfigSQL updating storage")
@ -279,7 +281,13 @@ def _migrate_table(session, orm_class):
if sys.version_info < (3, 0):
if isinstance(column.default.arg,unicode):
column.default.arg = column.default.arg.encode('utf-8')
column_default = "" if column.default is None else ("DEFAULT %r" % column.default.arg)
if column.default is None:
column_default = ""
else:
if isinstance(column.default.arg, bool):
column_default = ("DEFAULT %r" % int(column.default.arg))
else:
column_default = ("DEFAULT %r" % column.default.arg)
alter_table = "ALTER TABLE %s ADD COLUMN `%s` %s %s" % (orm_class.__tablename__,
column_name,
column.type,