The following documentation should be added to the Tripal DBX table prefixing documentation:
The most effective way to indicate that you are querying chado is to use the 1: prefix for your tablename.
If you use $connection->setSchema() then that is the schema that will be queried when the 1: prefix is added.
If you do not specifically set the schema as above then the default Tripal DBX schema for that site will be used. The default chado is set automatically by your site installation.
If you do not specify a prefix then Tripal DBX will try to guess which schema it should be using
In most cases, Tripal DBX will assume Drupal is the schema to use since the network of database calls often causes Tripal DBX to be unknowingly used by Drupal.
However, if the class making the database call is in a special Tripal DBX whitelist then the default Tripal DBX managed schema (often the default chado schema) will be used.
Additionally, Tripal DBX follows inheritance so any class your current class inherits from is in the whitelist then the default Tripal DBX managed schema will also be used.
To add your class to this whitelist you call useTripalDbxSchemaFor() on your connection with your class passed in.
Example: $connection->useTripalDbxSchemaFor(\Drupal\Tests\tripal_chado\Functional\ChadoConnectionTest::class); adds the ChadoConnectionTest class to the whitelist.
You should only add test classes while testing table prefixing. In most cases you will want to add the class you are testing.
For example, to ensure Tripal Importers were using the Tripal DBX managed schema by default we would add the base importer class to this whitelist when the connection is initiated.
Questions that should also be answered by this documentation but that I don't know the answer to:
How does one set the default Tripal DBX managed schema for a site? Can this be done through the UI?
If core uses the 1:tablename prefix and another module wants to impact what schema that refers to, is there a central place currently provided by Tripal DBX for altering connections made by other classes?
Is this class whitelist saved beyond the specific connection it was set on or does it only apply to that connection?
@guignonv if you have a moment, could you provide the answer to these questions? Also, did I get the description of how table prefixing is done correct above or is there an additional part to it that I have missed?
The following documentation should be added to the Tripal DBX table prefixing documentation:
1:
prefix for your tablename.1:
prefix is added.useTripalDbxSchemaFor()
on your connection with your class passed in.$connection->useTripalDbxSchemaFor(\Drupal\Tests\tripal_chado\Functional\ChadoConnectionTest::class);
adds the ChadoConnectionTest class to the whitelist.Questions that should also be answered by this documentation but that I don't know the answer to:
1:tablename
prefix and another module wants to impact what schema that refers to, is there a central place currently provided by Tripal DBX for altering connections made by other classes?@guignonv if you have a moment, could you provide the answer to these questions? Also, did I get the description of how table prefixing is done correct above or is there an additional part to it that I have missed?