[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Conditional entries with dbconfig-common



Moin,

I'm trying to fix #712991, and got frustratingly stuck at what is
clearly a lack of understanding from my part.

Drupal7 uses dbconfig-common to handle the database configuration. And
Drupal7 handles SQLite as well as MySQL and PostgreSQL. But the
configuration should be quite different (which is natural given the
different nature of said DBMSs): My current debian/dbconfig.template
reads (omitting comments and stuff):

/------------------------------------------------------------
| $databases['default']['default'] = array(
| 				 'driver' => '_DBC_DBTYPE_',
| 				 'database' => '_DBC_DBNAME_',
| 				 'username' => '_DBC_DBUSER_',
| 				 'password' => '_DBC_DBPASS_',
| 				 'host' => '_DBC_DBSERVER_',
| 				 'port' => '_DBC_DBPORT_',
| 				 'prefix' => '_DBC_BASEPATH_'
| );
\------------------------------------------------------------

So, for the currently supported cases, the output is correct as
follows:

/------------------------------------------------------------
| $databases['default']['default'] = array(
| 				 'driver' => 'mysql',
| 				 'database' => 'mydbname',
| 				 'username' => 'mydbuser',
| 				 'password' => 'f00bar',
| 				 'host' => 'localhost',
| 				 'port' => '',
| 				 'prefix' => ''
| );
\------------------------------------------------------------

However, for SQLite, the output reads:

/------------------------------------------------------------
| $databases['default']['default'] = array(
| 				 'driver' => 'sqlite',
| 				 'database' => 'drupal7',
| 				 'username' => '',
| 				 'password' => '',
| 				 'host' => 'localhost',
| 				 'port' => '',
| 				 'prefix' => '/var/lib/dbconfig-common/sqlite/drupal7'
| );
\------------------------------------------------------------

Most extra fields do not bother me (as they are ignored), but the
'prefix' field is ignored, and its contents should be prepended to the
'database'. What I would love to output is just:

/------------------------------------------------------------
| $databases['default']['default'] = array(
| 				 'driver' => 'sqlite',
| 				 'database' => '/var/lib/dbconfig-common/sqlite/drupal7/drupal7'
| );
\------------------------------------------------------------

Although I'd be reasonably happy with keeping the unneeded fields, outputting:

/------------------------------------------------------------
| $databases['default']['default'] = array(
| 				 'driver' => 'sqlite',
| 				 'database' => '/var/lib/dbconfig-common/sqlite/drupal7/drupal7',
| 				 'username' => '',
| 				 'password' => '',
| 				 'host' => '',
| 				 'port' => '',
| 				 'prefix' => ''
| );
\------------------------------------------------------------

However, this depends on having some sort of conditional handling in
the template. I could get around this by having something ugly like:


/------------------------------------------------------------
| $dbs['mysql'] = array(
|                       'driver' => '_DBC_DBTYPE_',
|                       'database' => '_DBC_DBNAME_',
|                       'username' => '_DBC_DBUSER_',
|                       'password' => '_DBC_DBPASS_',
|                       'host' => '_DBC_DBSERVER_',
|                       'port' => '_DBC_DBPORT_',
|                       'prefix' => '_DBC_BASEPATH_'
| );
| 
| $dbs['pgsql'] = array(
|                       'driver' => '_DBC_DBTYPE_',
|                       'database' => '_DBC_DBNAME_',
|                       'username' => '_DBC_DBUSER_',
|                       'password' => '_DBC_DBPASS_',
|                       'host' => '_DBC_DBSERVER_',
|                       'port' => '_DBC_DBPORT_',
|                       'prefix' => '_DBC_BASEPATH_'
| );
| 
| $dbs['sqlite'] = array(
|                       'driver' => '_DBC_DBTYPE_',
|                       'database' => '_DBC_BASEPATH_/_DBC_DBNAME_',
| );
| 
| $databases['default']['default'] = $dbs['_DBC_DBTYPE_'];
\------------------------------------------------------------

But of course, having this in what should just be a _configuration
file_ seems confusing and downright stupid to me :-/

Any ideas?


Reply to: