-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chado_db_query must be improved #863
Comments
we have a PR up at #867 . In making it we uncovered a problem that we need a decision on.
I think its confusing to have the two APIs behave differently. I think its cleaner if we factor out the table string replacement so that both methods can use it. However, requiring chado_db_query to have table prefixes would be a breaking change. Its only used in one place in core's code, so easy fix there. however, other modules might be using it. presumably outside of a db transaction because within one the function doesnt work. |
I think I have a solution that is not a breaking change. We can do the following:
If we do it this way, every one is happy! |
I vote for consistency (i.e. keeping the table prefixing for both) especially if it can be a non-breaking change |
So I guess to make sure it is none breaking we have to implement it as I suggested above. We should also add a deprecation notice to the old way of doing things and make people aware that this will change in the future. Agreed? |
We are not different than Drupal's API. But there is still the problem of accessing non-Chado tables. |
An idea.... My preference would be to keep One thing I'm not sure of is will using |
A quick update on this. Over a discussion on Slack, it's been decided that |
The associated PR has been merged so I'm closing this issue. If there was anything unresolved by the PR please comment and we will re-open! |
Feature Request/Discussion
edit: i wrote this issue thinking we need to fix the lack of join support but really i think the base class is just broken. see this basic test which is failing right now.
Description
the
chado_db_query()
function returns aChadoDatabaseConnection
see here. I'm using it as per our discussion in the #774 instead ofdb_select('chado.table_name')
.However, what if i need to join to another chado table?
this wont work. It should function similarly to chado_query where the chado table names go in a
{}
and are replaced by the API.consider this failing test:
I can think of other problems. How do i join across public and chado schema with this method? What if i want to start from a public table and join into a chado table?
additional problems?
switching to chado_db_select breaks my functionality but perhaps i'm using it wrong.
it looks like db_query returns a SelectQuery object https://api.drupal.org/api/drupal/includes%21database%21select.inc/class/SelectQuery/7.x
whereas chado_db_select extends a
DatabaseConnection_pgsql
objectObserve below:
as you can see using a plain db_query specifying chado retrieves the analysis,, but using the chado_db_select does not.
UPDATE: I've figured it out.
chado_db_select
is NOT compatible with Tripal Test Suite transactions whereasdb_select
is. If you turn off transactions, this failing test will pass.proposal
This method should accept table names in
{}
and[]
likechado_query
does to differentiate between chado and public. It should accept them whenever you put in tables instead of aliases (join and select at least).The text was updated successfully, but these errors were encountered: