tripal / t4d8

This is a temporary repository for Drupal 9 upgrade for Tripal v4. It is meant to house issues related to the upgrade.
GNU General Public License v2.0
1 stars 10 forks source link

Tripal DBX, Drupal Query Builder + guessing default database #294

Closed laceysanderson closed 1 year ago

laceysanderson commented 1 year ago

This came up in #274. In PR #290 we added support/documentation for Tripal DBX to guess that even if the table is not prefixed in some cases you would want to use Chado anyway. For example, you should be able to do $connection->query("SELECT * FROM {feature}"); and even though it's not {1:feature} Tripal DBX should know to use Chado.

While the above case now works, the query builder does not seem to allow this right now. For example, $connection->select('feature', 'f') will not work as Tripal DBX is assuming this is a Drupal table. This is very noticable in automated testing where queries start failing with weird test12432342342 prefixes to the table name.

Using the same approach as in #290 doesn't work here since only the query builder classes show up in the backtrace.

laceysanderson commented 1 year ago

In the meantime, using the 1 prefix to your table name fixes the problem. When this issue is fixed it will also update the existing places Tripal DBX query builder has been used.

For example,

$select = $chado->select('1:'.$chado_table, 'ct');
laceysanderson commented 1 year ago

This has been fixed. More documentation will be added in tripal_doc