bigpresh / Dancer-Plugin-Database

Dancer::Plugin::Database - easy database support for Dancer applications
http://search.cpan.org/dist/Dancer-Plugin-Database
37 stars 36 forks source link

Make Multiple Connections Share the Main Settings #100

Open mikkoi opened 4 years ago

mikkoi commented 4 years ago

I have the following parameters in development.yml:

plugins:
    Database:
        connections:
            rw:
                driver: SQLite
                database: 'db.sqlite'
                dbi_params:
                    RaiseError: 1
                    AutoCommit: 1
                    ReadOnly: 0
                    TaintIn: 1
                    TaintOut: 1
                    RaiseError: 1
                    PrintError: 1
                    printWarn: 1
                on_connect_do: [ "PRAGMA foreign_keys = ON" ]
                log_queries: 1
            r:
                driver: SQLite
                database: 'db.sqlite'
                dbi_params:
                    RaiseError: 1
                    AutoCommit: 1
                    ReadOnly: 1
                    TaintIn: 1
                    TaintOut: 1
                    RaiseError: 1
                    PrintError: 1
                    printWarn: 1
                log_queries: 1

I would instead like to share the common parameters, like this:

plugins:
    Database:
        driver: SQLite
        database: 'db.sqlite'
        dbi_params:
            RaiseError: 1
            AutoCommit: 1
            TaintIn: 1
            TaintOut: 1
            RaiseError: 1
            PrintError: 1
            printWarn: 1
        log_queries: 1
        connections:
            rw:
                dbi_params:
                    ReadOnly: 0
                on_connect_do: [ "PRAGMA foreign_keys = ON" ]
            r:
                dbi_params:
                    ReadOnly: 1