Kdyby / Doctrine

Doctrine 2 ORM integration into Nette Framework
https://packagist.org/packages/kdyby/doctrine
Other
110 stars 101 forks source link

Use default Doctrine config in OrmExtension #241

Open foxycode opened 8 years ago

foxycode commented 8 years ago

Connection setting is under doctrine / dbal / connections DoctrineBundle: http://symfony.com/doc/current/reference/configuration/doctrine.html

I'd like it same way to not think what is different in Kdyby\Doctrine against default implementation.

I currently using config like this:

doctrine:
    metadata:
        App\Model\Entities: %appDir%/model/Entities
    types:
        convertabledatetime: App\Model\ConvertableDateTimeType
    dql:
        datetime:
            date:           Oro\ORM\Query\AST\Functions\SimpleFunction
            time:           Oro\ORM\Query\AST\Functions\SimpleFunction
            timestamp:      Oro\ORM\Query\AST\Functions\SimpleFunction
            convert_tz:     Oro\ORM\Query\AST\Functions\DateTime\ConvertTz
            timestampdiff:  Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff
            dayofyear:      Oro\ORM\Query\AST\Functions\SimpleFunction
            dayofmonth:     Oro\ORM\Query\AST\Functions\SimpleFunction
            dayofweek:      Oro\ORM\Query\AST\Functions\SimpleFunction
            week:           Oro\ORM\Query\AST\Functions\SimpleFunction
            day:            Oro\ORM\Query\AST\Functions\SimpleFunction
            hour:           Oro\ORM\Query\AST\Functions\SimpleFunction
            minute:         Oro\ORM\Query\AST\Functions\SimpleFunction
            month:          Oro\ORM\Query\AST\Functions\SimpleFunction
            quarter:        Oro\ORM\Query\AST\Functions\SimpleFunction
            second:         Oro\ORM\Query\AST\Functions\SimpleFunction
            year:           Oro\ORM\Query\AST\Functions\SimpleFunction
        numeric:
            sign:           Oro\ORM\Query\AST\Functions\Numeric\Sign
            pow:            Oro\ORM\Query\AST\Functions\Numeric\Pow
        string:
            group_concat:   Oro\ORM\Query\AST\Functions\String\GroupConcat
            concat_ws:      Oro\ORM\Query\AST\Functions\String\ConcatWs
            cast:           Oro\ORM\Query\AST\Functions\Cast
    default:
        driver: pdo_mysql
        host: localhost
        user: xxx
        password: xxx
        dbname: xxx
    deals:
        driver: pdo_pgsql
        host: localhost
        user: xxx
        password: xxx
        dbname: xxx

I have it splitted to more neon files of course, but still it is weird to have connection names on same level that another config sections. It then creates another problems like this: https://github.com/mrtnzlml/testbench/pull/14

fprochazka commented 8 years ago

That is not "default implementation", but symfony's custom config structure. I wouldn't wanna break the compatibility just to be compliant with symfony.

Your configuration can be rewritten to this

doctrine:
    default:
        driver: pdo_mysql
        host: localhost
        user: xxx
        password: xxx
        dbname: xxx
        metadata:
            App\Model\Entities: %appDir%/model/Entities
    deals:
        driver: pdo_pgsql
        host: localhost
        user: xxx
        password: xxx
        dbname: xxx
        metadata:
            App\Model\Entities: %appDir%/model/Entities
    types:
        convertabledatetime: App\Model\ConvertableDateTimeType
    dql:
        datetime:
            date:           Oro\ORM\Query\AST\Functions\SimpleFunction
            time:           Oro\ORM\Query\AST\Functions\SimpleFunction
            timestamp:      Oro\ORM\Query\AST\Functions\SimpleFunction
            convert_tz:     Oro\ORM\Query\AST\Functions\DateTime\ConvertTz
            timestampdiff:  Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff
            dayofyear:      Oro\ORM\Query\AST\Functions\SimpleFunction
            dayofmonth:     Oro\ORM\Query\AST\Functions\SimpleFunction
            dayofweek:      Oro\ORM\Query\AST\Functions\SimpleFunction
            week:           Oro\ORM\Query\AST\Functions\SimpleFunction
            day:            Oro\ORM\Query\AST\Functions\SimpleFunction
            hour:           Oro\ORM\Query\AST\Functions\SimpleFunction
            minute:         Oro\ORM\Query\AST\Functions\SimpleFunction
            month:          Oro\ORM\Query\AST\Functions\SimpleFunction
            quarter:        Oro\ORM\Query\AST\Functions\SimpleFunction
            second:         Oro\ORM\Query\AST\Functions\SimpleFunction
            year:           Oro\ORM\Query\AST\Functions\SimpleFunction
        numeric:
            sign:           Oro\ORM\Query\AST\Functions\Numeric\Sign
            pow:            Oro\ORM\Query\AST\Functions\Numeric\Pow
        string:
            group_concat:   Oro\ORM\Query\AST\Functions\String\GroupConcat
            concat_ws:      Oro\ORM\Query\AST\Functions\String\ConcatWs
            cast:           Oro\ORM\Query\AST\Functions\Cast

basically everything should be possible to add only to the section of the named configuration (under default or deals).

fprochazka commented 8 years ago

Let me think about this a bit more, it might not be a bad idea to be compatible, but at this point, before refactoring most of this library out ( #238 ), there would be a lot of unnecesary overhead even if you'd did it - I'd still have to review&test&merge it.

foxycode commented 8 years ago

@fprochazka I wouldn't suggest such BC break if you didn't planned release 4.0 :) Let me know if I can help. If you give me some guidance, we can minimize your review work and my refactoring.