Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ORM] model Table annotation #39

Closed
jyyan opened this issue May 7, 2019 · 2 comments · Fixed by #40
Closed

[ORM] model Table annotation #39

jyyan opened this issue May 7, 2019 · 2 comments · Fixed by #40
Assignees
Labels
bug Fixed Fixed bug

Comments

@jyyan
Copy link
Contributor

jyyan commented May 7, 2019

Steps

Hello ,

ref as [part] ORM Table annotation #14

I got the
@table("db_table_name")
work for me, but
@table("name"=>"db_table_name")
is not work.

then i found that the TableAnnotation L22 only check & take the array $properties[0] as annotation name. but missing to check map $properties['name']

when i patch with below it work fine for me

/**
* Initialize the annotation.
*/
public function initAnnotation(array $properties) {
    error_log(var_export($properties, true));
    /*
        array (
        'name' => 'db_table_name',
        )
    */
    if (isset ( $properties [0] )) {
        $this->name = $properties [0];
        unset ( $properties [0] );
    } else if (isset ( $properties ['name'] )) {
        $this->name = $properties ['name'];
        unset ( $properties ['name'] );
    } else {
        throw new \Exception ( 'Table annotation must have a name' );
    }
}

Expected Result

Actual Result

PHP Fatal error:  Uncaught Exception: Table annotation must have a name in /vendor/phpmv/ubiquity/src/Ubiquity/annotations/TableAnnotation.php:27
Stack trace:
#0 /vendor/mindplay/annotations/src/annotations/AnnotationManager.php(296): Ubiquity\annotations\TableAnnotation->initAnnotation(Array)
#1 /vendor/mindplay/annotations/src/annotations/AnnotationManager.php(263): mindplay\annotations\AnnotationManager->getAnnotations('models\\Sys_logs', 'class')
#2 /vendor/mindplay/annotations/src/annotations/AnnotationManager.php(594): mindplay\annotations\AnnotationManager->getAnnotations('models\\Sys_logs', 'property', '$id')
#3 /vendor/mindplay/annotations/src/annotations/Annotations.php(90): mindplay\annotations\AnnotationManager->getPropertyAnnotations('models\\S in /vendor/phpmv/ubiquity/src/Ubiquity/annotations/TableAnnotation.php on line 27

Versions

· PHP 7.1.27-1+ubuntu18.04.1+deb.sury.org+1
· Ubiquity devtools (1.2.3)
· Ubiquity 2.1.2

jyyan added a commit to jyyan/ubiquity that referenced this issue May 7, 2019
@jcheron jcheron added the bug label May 7, 2019
@jcheron
Copy link
Contributor

jcheron commented May 7, 2019

Hi @jyyan ,
Can you make a PR with these modifications?
note:
You can remove the line:

unset ( $properties ['name']);

useless

@jyyan
Copy link
Contributor Author

jyyan commented May 7, 2019

thanks @jcheron

jcheron added a commit that referenced this issue May 7, 2019
small patch for fix [ORM] model Table annotation #39
@jcheron jcheron added the Fixed Fixed bug label May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixed Fixed bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants