mirror of
https://github.com/danog/AsyncOrm.git
synced 2024-11-30 04:39:45 +01:00
Compare commits
4 Commits
c820a4023a
...
a448696930
Author | SHA1 | Date | |
---|---|---|---|
|
a448696930 | ||
1a5129adea | |||
|
fe29289045 | ||
5035c06615 |
@ -5,7 +5,7 @@
|
|||||||
[![Psalm level 1](https://shepherd.dev/github/danog/AsyncOrm/level.svg)](https://shepherd.dev/github/danog/AsyncOrm)
|
[![Psalm level 1](https://shepherd.dev/github/danog/AsyncOrm/level.svg)](https://shepherd.dev/github/danog/AsyncOrm)
|
||||||
![License](https://img.shields.io/github/license/danog/AsyncOrm)
|
![License](https://img.shields.io/github/license/danog/AsyncOrm)
|
||||||
|
|
||||||
Async ORM based on AMPHP v3 and fibers, created by Daniil Gentili (https://daniil.it) and Alexander Pankratov (alexander@i-c-a.su).
|
Async ORM based on AMPHP v3 and fibers, created by Daniil Gentili (https://daniil.it) and Alexander Pankratov (https://github.com/xtrime-ru).
|
||||||
|
|
||||||
Supports MySQL, Redis, Postgres.
|
Supports MySQL, Redis, Postgres.
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ For optimal performance, the specified types must be as strict as possible, here
|
|||||||
* `ValueType::INT`: Direct storage of integer values.
|
* `ValueType::INT`: Direct storage of integer values.
|
||||||
* `ValueType::BOOL`: Direct storage of boolean values.
|
* `ValueType::BOOL`: Direct storage of boolean values.
|
||||||
* `ValueType::FLOAT`: Direct storage of floating point (double precision) values.
|
* `ValueType::FLOAT`: Direct storage of floating point (double precision) values.
|
||||||
* `ValueType::SCALAR`: Values of any scalar type (including arrays, excluding objects), serialized as specified in the settings.
|
* `ValueType::SCALAR`: Values of any scalar type (including blobs and arrays, excluding objects), serialized as specified in the settings.
|
||||||
Using SCALAR worsens performances, please use any of the other types if possible.
|
Using SCALAR worsens performances, please use any of the other types if possible.
|
||||||
* `ValueType::OBJECT`: Objects extending DbObject, serialized as specified in the settings.
|
* `ValueType::OBJECT`: Objects extending DbObject, serialized as specified in the settings.
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ namespace danog\AsyncOrm\Annotations;
|
|||||||
|
|
||||||
use Attribute;
|
use Attribute;
|
||||||
use danog\AsyncOrm\KeyType;
|
use danog\AsyncOrm\KeyType;
|
||||||
|
use danog\AsyncOrm\Serializer;
|
||||||
use danog\AsyncOrm\ValueType;
|
use danog\AsyncOrm\ValueType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +55,11 @@ final class OrmMappedArray
|
|||||||
/**
|
/**
|
||||||
* Table name postfix, if null defaults to the property name.
|
* Table name postfix, if null defaults to the property name.
|
||||||
*/
|
*/
|
||||||
public readonly ?string $tablePostfix = null
|
public readonly ?string $tablePostfix = null,
|
||||||
|
/**
|
||||||
|
* Provide custom serializer for table.
|
||||||
|
*/
|
||||||
|
public readonly ?Serializer $serializer = null,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,13 @@ trait DbAutoProperties
|
|||||||
['cacheTtl' => $ttl]
|
['cacheTtl' => $ttl]
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
$serializer = $attr->serializer ?? $settings->serializer;
|
||||||
|
if ($serializer !== $settings->serializer) {
|
||||||
|
$settings = new $settings(...\array_merge(
|
||||||
|
(array) $settings,
|
||||||
|
['serializer' => $serializer]
|
||||||
|
));
|
||||||
|
}
|
||||||
if ($settings instanceof MysqlSettings) {
|
if ($settings instanceof MysqlSettings) {
|
||||||
$optimize = $attr->optimizeIfWastedMb ?? $settings->optimizeIfWastedMb;
|
$optimize = $attr->optimizeIfWastedMb ?? $settings->optimizeIfWastedMb;
|
||||||
|
|
||||||
|
@ -433,8 +433,10 @@ final class OrmTest extends TestCase
|
|||||||
|
|
||||||
$obj->arr[12345] = 54321;
|
$obj->arr[12345] = 54321;
|
||||||
$obj->arr2[123456] = 654321;
|
$obj->arr2[123456] = 654321;
|
||||||
|
$obj->arr5[123] = "7734";
|
||||||
$this->assertSame(54321, $obj->arr[12345]);
|
$this->assertSame(54321, $obj->arr[12345]);
|
||||||
$this->assertSame(654321, $obj->arr2[123456]);
|
$this->assertSame(654321, $obj->arr2[123456]);
|
||||||
|
$this->assertSame("7734", $obj->arr5[123]);
|
||||||
$this->assertCount(1, $obj->arr);
|
$this->assertCount(1, $obj->arr);
|
||||||
$this->assertCount(1, $obj->arr2);
|
$this->assertCount(1, $obj->arr2);
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ use danog\AsyncOrm\DbArrayBuilder;
|
|||||||
use danog\AsyncOrm\DbAutoProperties;
|
use danog\AsyncOrm\DbAutoProperties;
|
||||||
use danog\AsyncOrm\DbObject;
|
use danog\AsyncOrm\DbObject;
|
||||||
use danog\AsyncOrm\KeyType;
|
use danog\AsyncOrm\KeyType;
|
||||||
|
use danog\AsyncOrm\Serializer\Json;
|
||||||
use danog\AsyncOrm\ValueType;
|
use danog\AsyncOrm\ValueType;
|
||||||
|
|
||||||
final class TestObject extends DbObject
|
final class TestObject extends DbObject
|
||||||
@ -67,6 +68,14 @@ final class TestObject extends DbObject
|
|||||||
)]
|
)]
|
||||||
public DbArray $arr4;
|
public DbArray $arr4;
|
||||||
|
|
||||||
|
#[OrmMappedArray(
|
||||||
|
keyType: KeyType::INT,
|
||||||
|
valueType: ValueType::SCALAR,
|
||||||
|
cacheTtl: 0,
|
||||||
|
serializer: new Json(),
|
||||||
|
)]
|
||||||
|
public DbArray $arr5;
|
||||||
|
|
||||||
public function __sleep()
|
public function __sleep()
|
||||||
{
|
{
|
||||||
return ['savedProp', 'arr', 'arr2', 'arr3', 'arr4'];
|
return ['savedProp', 'arr', 'arr2', 'arr3', 'arr4'];
|
||||||
|
Loading…
Reference in New Issue
Block a user