- WIP on SQLite Adapter and migration

This commit is contained in:
mcndave committed 2023-03-27 18:38:31 +00:00
1 parent cee978ecfd
commit 9514a46ae7
14 files changed
+98 -40

No files matched your search

+9 -3
View File
@@ -3,6 +3,7 @@
namespace Ulmus\Adapter;
use Ulmus\Common\PdoObject;
use Ulmus\ConnectionAdapter;
use Ulmus\Entity\Sqlite\Table;
use Ulmus\Exception\AdapterConfigurationException;
@@ -11,6 +12,9 @@ use Ulmus\{Repository, QueryBuilder, Ulmus};
class SQLite implements AdapterInterface {
use DefaultAdapterTrait;
const ALLOWED_ATTRIBUTES = [
'default', 'primary_key', 'auto_increment'
];
const DSN_PREFIX = "sqlite";
@@ -87,9 +91,11 @@ class SQLite implements AdapterInterface {
return substr($base, 0, strrpos($base, '.') ?: strlen($base));
}
public function schemaTable(string $databaseName, string $tableName) : null|object
public function schemaTable(ConnectionAdapter $adapter, string $databaseName, string $tableName) : null|object
{
return Table::repository()->loadOneFromField(Table::field('tableName'), $tableName);
return Table::repository(Repository::DEFAULT_ALIAS, $adapter)
->select(\Ulmus\Common\Sql::raw('this.*'))
->loadOneFromField(Table::field('tableName'), $tableName);
}
public function mapFieldType(FieldDefinition $field, bool $typeOnly = false) : string
@@ -197,4 +203,4 @@ class SQLite implements AdapterInterface {
$pdo->sqliteCreateFunction('month', fn($date) => ( new \DateTime($date) )->format('m'), 1);
$pdo->sqliteCreateFunction('year', fn($date) => ( new \DateTime($date) )->format('Y'), 1);
}
}
}