Skip to content

Commit 9a9c79d

Browse files
authored
remove native database types thing (#61)
1 parent 97ad562 commit 9a9c79d

File tree

6 files changed

+7
-65
lines changed

6 files changed

+7
-65
lines changed

lib/Adapter/MysqlAdapter.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,24 +88,4 @@ public function accepts_limit_and_order_for_update_and_delete(): bool
8888
{
8989
return true;
9090
}
91-
92-
/**
93-
* @return array<string, string|array<string, mixed>>
94-
*/
95-
public function native_database_types(): array
96-
{
97-
return [
98-
'primary_key' => 'int(11) UNSIGNED DEFAULT NULL auto_increment PRIMARY KEY',
99-
'string' => ['name' => 'varchar', 'length' => 255],
100-
'text' => ['name' => 'text'],
101-
'integer' => ['name' => 'int', 'length' => 11],
102-
'float' => ['name' => 'float'],
103-
'datetime' => ['name' => 'datetime'],
104-
'timestamp' => ['name' => 'datetime'],
105-
'time' => ['name' => 'time'],
106-
'date' => ['name' => 'date'],
107-
'binary' => ['name' => 'blob'],
108-
'boolean' => ['name' => 'tinyint', 'length' => 1]
109-
];
110-
}
11191
}

lib/Adapter/PgsqlAdapter.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,4 @@ public function set_encoding(string $charset): void
135135
{
136136
$this->query("SET NAMES '$charset'");
137137
}
138-
139-
public function native_database_types(): array
140-
{
141-
return [
142-
'primary_key' => 'serial primary key',
143-
'string' => ['name' => 'character varying', 'length' => 255],
144-
'text' => ['name' => 'text'],
145-
'integer' => ['name' => 'integer'],
146-
'float' => ['name' => 'float'],
147-
'datetime' => ['name' => 'datetime'],
148-
'timestamp' => ['name' => 'timestamp'],
149-
'time' => ['name' => 'time'],
150-
'date' => ['name' => 'date'],
151-
'binary' => ['name' => 'binary'],
152-
'boolean' => ['name' => 'boolean']
153-
];
154-
}
155138
}

lib/Adapter/SqliteAdapter.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,4 @@ public function accepts_limit_and_order_for_update_and_delete(): bool
108108
{
109109
return true;
110110
}
111-
112-
public function native_database_types(): array
113-
{
114-
return [
115-
'primary_key' => 'integer not null primary key',
116-
'string' => ['name' => 'varchar', 'length' => 255],
117-
'text' => ['name' => 'text'],
118-
'integer' => ['name' => 'integer'],
119-
'float' => ['name' => 'float'],
120-
'decimal' => ['name' => 'decimal'],
121-
'datetime' => ['name' => 'datetime'],
122-
'timestamp' => ['name' => 'datetime'],
123-
'time' => ['name' => 'time'],
124-
'date' => ['name' => 'date'],
125-
'binary' => ['name' => 'blob'],
126-
'boolean' => ['name' => 'boolean']
127-
];
128-
}
129111
}

lib/Connection.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -563,15 +563,6 @@ abstract public function query_for_tables(): \PDOStatement;
563563
*/
564564
abstract public function set_encoding(string $charset): void;
565565

566-
/*
567-
* Returns an array mapping of native database types
568-
*/
569-
570-
/**
571-
* @return array<string, string|array<string, mixed>>
572-
*/
573-
abstract public function native_database_types(): array;
574-
575566
/**
576567
* Specifies whether adapter can use LIMIT/ORDER clauses with DELETE & UPDATE operations
577568
*

lib/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function reestablish_connection(bool $close = true): Connection
133133
$connection = $this->class->getStaticPropertyValue('connection', null);
134134

135135
if ($close) {
136-
ConnectionManager::drop_connection($connection);
136+
ConnectionManager::drop_connection($connection ?? '');
137137
static::clear_cache();
138138
}
139139

test/ConnectionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,10 @@ public function testEncoding()
7474
$info = ActiveRecord\Connection::parse_connection_url('mysql://test:test@127.0.0.1/test?charset=utf8');
7575
$this->assertEquals('utf8', $info['charset']);
7676
}
77+
78+
public function testReestablishConnection()
79+
{
80+
$connection = \test\models\Book::reestablish_connection(true);
81+
$this->assertNotNull($connection);
82+
}
7783
}

0 commit comments

Comments
 (0)