laravel / ideas

Issues board used for Laravel internals discussions.
939 stars 28 forks source link

Set custom SQL grammar, schema and processor on the connection configuration. #2615

Closed juanparati closed 3 years ago

juanparati commented 3 years ago

Right now in order to register a custom grammar, schema or processor we have to do it directly into a service provider using for example the "setSchemaGrammar", "setQueryGrammar", etc.

I propose that custom query grammars, schemas and processors can be overrided/added directly into the "database.connections" configuration.

Example:

'bigquery' => [
            'driver'   => 'odbc',
            'dsn'      => 'odbc:Driver=/opt/simba/BigQueryODBC/lib/libgooglebigqueryodbc_sb64.so;Catalog=public-data;SQLDialect=1;OAuthMechanism=0;Email=foo@bar.iam.gserviceaccount.com;KeyFilePath=/home/vagrant/testapp/code/.bigquery_service.json;AllowLargeResults=0',
            'database' => 'public',
            'grammar' => [
                'query' => \App\Grammars\BigQuery\BigQueryQueryGrammar::class,
                'schema' => \App\Grammars\BigQuery\BigQuerySchemaGrammar::class,
            ],
            'processor' => \App\Grammars\BigQuery\BigQueryProcessor::class,
        ],
themsaid commented 3 years ago

I don't think that's a good idea. Using a service provider is the way to go.