Another MariaDB JSON fix
This commit is contained in:
parent
f64e226703
commit
15762350d2
@ -304,6 +304,7 @@ class MySQL extends SQL {
|
|||||||
|
|
||||||
public function getColumnDefinition($column) {
|
public function getColumnDefinition($column) {
|
||||||
$columnName = $column->getName();
|
$columnName = $column->getName();
|
||||||
|
$defaultValue = $column->getDefaultValue();
|
||||||
|
|
||||||
if ($column instanceof StringColumn) {
|
if ($column instanceof StringColumn) {
|
||||||
$maxSize = $column->getMaxSize();
|
$maxSize = $column->getMaxSize();
|
||||||
@ -330,15 +331,17 @@ class MySQL extends SQL {
|
|||||||
$type = "BOOLEAN";
|
$type = "BOOLEAN";
|
||||||
} else if($column instanceof JsonColumn) {
|
} else if($column instanceof JsonColumn) {
|
||||||
$type = "LONGTEXT"; # some maria db setups don't allow JSON here…
|
$type = "LONGTEXT"; # some maria db setups don't allow JSON here…
|
||||||
|
$defaultValue = NULL; # must be null :(
|
||||||
} else {
|
} else {
|
||||||
$this->lastError = "Unsupported Column Type: " . get_class($column);
|
$this->lastError = "Unsupported Column Type: " . get_class($column);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$notNull = $column->notNull() ? " NOT NULL" : "";
|
$notNull = $column->notNull() ? " NOT NULL" : "";
|
||||||
$defaultValue = "";
|
if (!is_null($defaultValue) || !$column->notNull()) {
|
||||||
if (!is_null($column->getDefaultValue()) || !$column->notNull()) {
|
|
||||||
$defaultValue = " DEFAULT " . $this->getValueDefinition($column->getDefaultValue());
|
$defaultValue = " DEFAULT " . $this->getValueDefinition($column->getDefaultValue());
|
||||||
|
} else {
|
||||||
|
$defaultValue = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "`$columnName` $type$notNull$defaultValue";
|
return "`$columnName` $type$notNull$defaultValue";
|
||||||
|
@ -125,7 +125,7 @@ class User extends ApiObject {
|
|||||||
$this->username = $row['name'];
|
$this->username = $row['name'];
|
||||||
$this->uid = $userId;
|
$this->uid = $userId;
|
||||||
$this->session = new Session($this, $sessionId);
|
$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"]);
|
$this->session->stayLoggedIn($row["stay_logged_in"]);
|
||||||
if($sessionUpdate) $this->session->update();
|
if($sessionUpdate) $this->session->update();
|
||||||
$this->loggedIn = true;
|
$this->loggedIn = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user