diff --git a/core/Driver/SQL/MySQL.class.php b/core/Driver/SQL/MySQL.class.php index a7e3831..057e52e 100644 --- a/core/Driver/SQL/MySQL.class.php +++ b/core/Driver/SQL/MySQL.class.php @@ -304,6 +304,7 @@ class MySQL extends SQL { public function getColumnDefinition($column) { $columnName = $column->getName(); + $defaultValue = $column->getDefaultValue(); if ($column instanceof StringColumn) { $maxSize = $column->getMaxSize(); @@ -330,15 +331,17 @@ class MySQL extends SQL { $type = "BOOLEAN"; } else if($column instanceof JsonColumn) { $type = "LONGTEXT"; # some maria db setups don't allow JSON hereā€¦ + $defaultValue = NULL; # must be null :( } else { $this->lastError = "Unsupported Column Type: " . get_class($column); return NULL; } $notNull = $column->notNull() ? " NOT NULL" : ""; - $defaultValue = ""; - if (!is_null($column->getDefaultValue()) || !$column->notNull()) { + if (!is_null($defaultValue) || !$column->notNull()) { $defaultValue = " DEFAULT " . $this->getValueDefinition($column->getDefaultValue()); + } else { + $defaultValue = ""; } return "`$columnName` $type$notNull$defaultValue"; diff --git a/core/Objects/User.class.php b/core/Objects/User.class.php index 28de1af..40628a1 100644 --- a/core/Objects/User.class.php +++ b/core/Objects/User.class.php @@ -125,7 +125,7 @@ class User extends ApiObject { $this->username = $row['name']; $this->uid = $userId; $this->session = new Session($this, $sessionId); - $this->session->setData(json_decode($row["data"])); + $this->session->setData(json_decode($row["data"] ?? '{}')); $this->session->stayLoggedIn($row["stay_logged_in"]); if($sessionUpdate) $this->session->update(); $this->loggedIn = true;