Skip to content

refactor(db): Introduce new API for entities#1595

Open
CarlSchwan wants to merge 5 commits into
masterfrom
carl/entity
Open

refactor(db): Introduce new API for entities#1595
CarlSchwan wants to merge 5 commits into
masterfrom
carl/entity

Conversation

@CarlSchwan

@CarlSchwan CarlSchwan commented Jun 11, 2026

Copy link
Copy Markdown
Member

To be upstreamed later to server

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Signed-off-by: Carl Schwan <carlschwan@kde.org>
Signed-off-by: Carl Schwan <carlschwan@kde.org>
@CarlSchwan CarlSchwan changed the title refactor(db): Introduce repository concept refactor(db): Introduce new API for entities Jun 11, 2026
Comment thread lib/AppFramework/Db/Attribute/Column.php Outdated
Comment thread lib/AppFramework/Db/Attribute/Entity.php Outdated
Signed-off-by: Carl Schwan <carlschwan@kde.org>
Comment thread lib/AppFramework/Db/Attribute/Column.php
Signed-off-by: Carl Schwan <carlschwan@kde.org>
Signed-off-by: Carl Schwan <carlschwan@kde.org>
}

/** @var Column $columnAttribute */
$columnAttribute = $columnAttributes[0]->newInstance();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that there is only one column attribute on the property?

/** @var list<\ReflectionAttribute<Id>> $ids */
$ids = $property->getAttributes(Id::class, \ReflectionAttribute::IS_INSTANCEOF);
if ($ids !== []) {
$this->idProperty = $property;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show an error if there is already another id property?

* @param array<string, mixed> $row
* @return T
*/
private function mapRowToEntity(mixed $row): object {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private function mapRowToEntity(mixed $row): object {
private function mapRowToEntity(array $row): object {

->executeStatement();

if (!$isSnowflake) {
$primaryProperty->setValue($entity, $insert->getLastInsertId());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if no primary property? Should throw or adapt

$type = $this->getParameterType($this->_mappingColumnToTypes[$column], is_array($value));
if (is_array($value)) {
// IN expression
$qb->andWhere($qb->expr()->in($column, $qb->createNamedParameter($value, $type)));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chunking needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants