modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2025-04-28 05:06:17 +04:00
parent cae38dae95
commit 299b90c85e
3 changed files with 14 additions and 9 deletions

View File

@ -175,24 +175,24 @@ EOT;
]; ];
protected function _prepareMetadata(): void { protected function _prepareMetadata(): void {
if (!$this->tableExists(self::METADATA_TABLE)) { if (!$this->tableExists(static::METADATA_TABLE)) {
$db = $this->db(); $db = $this->db();
$db->exec([ $db->exec([
"drop table", "drop table if exists",
"table" => self::CHANNELS_TABLE, "table" => self::CHANNELS_TABLE,
]); ]);
$db->exec([ $db->exec([
"drop table", "drop table if exists",
"table" => _migration::MIGRATION_TABLE "table" => _migration::MIGRATION_TABLE
]); ]);
$db->exec([ $db->exec([
"create table", "create table",
"table" => self::METADATA_TABLE, "table" => static::METADATA_TABLE,
"cols" => self::METADATA_COLS, "cols" => static::METADATA_COLS,
]); ]);
$db->exec([ $db->exec([
"insert", "insert",
"into" => self::METADATA_TABLE, "into" => static::METADATA_TABLE,
"values" => [ "values" => [
"name" => "version", "name" => "version",
"value" => "1", "value" => "1",
@ -205,7 +205,7 @@ EOT;
const CHANNELS_TABLE = "_channels"; const CHANNELS_TABLE = "_channels";
const CHANNELS_COLS = [ const CHANNELS_COLS = [
"name" => "varchar primary key", "name" => "varchar not null primary key",
"table_name" => "varchar", "table_name" => "varchar",
"class_name" => "varchar", "class_name" => "varchar",
]; ];

View File

@ -83,7 +83,7 @@ class _select extends _common {
## from ## from
$from = $query["from"] ?? null; $from = $query["from"] ?? null;
if (self::consume('from\s+([a-z_][a-z0-9_]*)\s*(?=;?\s*$|\bwhere\b)', $tmpsql, $ms)) { if (self::consume('from\s+([a-z_][a-z0-9_.]*)\s*(?=;?\s*$|\bwhere\b)', $tmpsql, $ms)) {
if ($from === null) $from = $ms[1]; if ($from === null) $from = $ms[1];
$sql[] = "from"; $sql[] = "from";
$sql[] = $from; $sql[] = $from;

View File

@ -35,6 +35,11 @@ class MysqlStorage extends CapacitorStorage {
return $found !== null; return $found !== null;
} }
const METADATA_COLS = [
"name" => "varchar(64) not null primary key",
"value" => "varchar(255)",
];
function _getMigration(CapacitorChannel $channel): _mysqlMigration { function _getMigration(CapacitorChannel $channel): _mysqlMigration {
return new _mysqlMigration(cl::merge([ return new _mysqlMigration(cl::merge([
$this->_createSql($channel), $this->_createSql($channel),
@ -47,7 +52,7 @@ class MysqlStorage extends CapacitorStorage {
} }
const CHANNELS_COLS = [ const CHANNELS_COLS = [
"name" => "varchar(255) primary key", "name" => "varchar(255) not null primary key",
"table_name" => "varchar(64)", "table_name" => "varchar(64)",
"class_name" => "varchar(255)", "class_name" => "varchar(255)",
]; ];