nextras / orm Goto Github PK
View Code? Open in Web Editor NEWOrm with clean object design, smart relationship loading and powerful collections.
Home Page: https://nextras.org/orm
License: MIT License
Orm with clean object design, smart relationship loading and powerful collections.
Home Page: https://nextras.org/orm
License: MIT License
So. Yeah. Is there a documentation yet? If not, can I help documenting this lib? Is there a private draft or something? Since the 1.0 is in beta for quite a while now. I think it's somewhat past the time :)
On a related note (and I think I might have asked you earlier this fall), would you be interested in step by step manual for migrating from porm? If so, I would do that, but having a doc first would be great to prevent duplicated concept explanations.
If you run persist from the non-main side, relationship is not persisted.
was working...
Returning ResultSet or SqlBuilder works, but returning Selection does not.
After removing entity with composite primary key from collection, entity hasn't suffiect identification for removing from storage.
Related to fitak/fitak@889a973#commitcomment-8030742
What about returning NULL everywhere?
onBefore callback could load relationship, which wouldn't persited.
Have a fix, but I don't fully understand, need investigation.
Nextras\Orm\InvalidStateException: No primary keys detected for many has many 'contacts.contacts_x_contacts.tags' join table
In long-run processes it's quite commont we need to refetch actual state of entity in database. This api should be a little bit hidden in IdentityMap. refresh would refetch data and updated entity state. If entity isModified() === TRUE, exception should be thrown.
HasMany::$toAdd
, HasMany::$toRemove
Inflect::singularize($class) called in Repository::getEntityClassNames() destroy class name and AnnotationsParser throws ReflectionException #-1:
For example: Users, UsersRepository and UsersMapper not found because:
ReflectionException #-1 Class ORM\User does not exist
dump of $repositories:
secviceName => "orm.repositories.users",
name => "users",
entities => array("ORM\User"),
class => "ORM\UsersRepository"
some f* regression appeared.
Before 1.0 I would propably do some renames, which I would aware after releasing first stable version.
Namespaces:
Classes:
Methods:
Do you have any ideas to the suggested renames or new suggestions?
Would be nice, if enum annotation would accept method name, which would returned the allowed values.
filtering by Id when entity has composite key should automatically translate array param as argument for each part of composite key.
for pgsql
ToArrayConverter::toArray
should omit relationships when calling with type IEntity::TO_ARRAY_RELATIONSHIP_AS_IS
, but it doesn't. Instead, the output array contains Entity, OneHasMany, etc. instances on relationship keys.
In adc3e94 was implemented recursive removal. Eg. removing author removes also books, since books can't exists without defined author.
I'm thinking, if it wouldn't be better to don't make this recursive remove by default. If it's denied to recursive remove, orm will try set NULL value, which will throws exception.
So, default false would be safer.
ICollection
& IRelationshipCollection
implements Countable
.ArrayCollection
has already fetched entites, so count
counts array length.Collection
always run sql query to get the count.Would be nice to introduce API, which would allow to fetch entities and return the array count for Collection
. Possibilities:
Countable
interface and introduce optional (?) parameter, which will force the needed behaviour. NULL would probably means autodetect.countFetched
, countInStorage
. We could let the Countable
interface, or removed it either.Personally, I would like to avoid method parameter, since it's much less usable in templates, etc. However, I have no great idea about methods naming. Any suggests? cc @JanTvrdik
@property string $status {default self::SINGLE} {enum self::MARRIED self::SINGLE self::OTHER}
It would be nice to add api & possibility to filter & travers by filtered relationships. Such as
/**
* @property Comment[] $allComments {1:m CommentsRepository}
* @property-read Comment[] $comments {filter $allComments}
*/
class Post extends Entity
{
public function filterComments(ICollection $collection)
{
return $collection->findBy(['deletedAt' => NULL]);
}
}
// find all posts which were commented by lord Stark
// and these comments weren't deleted.
$this->orm->posts->findBy(['this->comments->author' => $lordStark->id]);
/**
* @property OneHasMany|FacebookComment[] $comments {1:m ContentsRepository $parent}
*/
class FacebookThread extends Orm\Entity\Entity {}
/**
* @property ManyHasOne|FacebookThread[] $parent {m:1 ContentsRepository $comments}
*/
class FacebookComment extends Orm\Entity\Entity {}
class ContentsRepository extends Orm\Repository\Repository
{
public static function getEntityClassNames()
{
return [
FacebookComment::class,
FacebookThread::class,
];
}
public function getEntityClassName(array $data = NULL)
{
if ($data === NULL)
{
return self::getEntityClassNames();
}
if (isset($data['type']) && class_exists($data['type']))
{
return $data['type'];
}
throw new InvalidStateException;
}
}
Expected behaviour is that the comments is only mapped on FacebookThread
which is specified in annotation. Instead it tries to map on all entities the repository manages, which fails on
Fitak\FacebookComment::$parent has not defined a symetric relationship in Fitak\FacebookComment::$comments.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.