Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I recently installed ubercart on oracle database and found that it is not supporting it. I came to conclusion that a lot of queries were written using db_query which are specific to mysql. I think we need to make use of pdo classes (db_select, db_update, db_insert, db_delete) so that it supports other databases too. Soon i will be submitting a patch for this as currently doing code changes to make this compatible.
Regards
Sagar
Comment | File | Size | Author |
---|---|---|---|
#10 | 1684266-oracle-compatibility.patch | 39.83 KB | longwave |
Comments
Comment #1
longwavedb_query() calls are not MySQL specific. Ubercart works fine on SQLite, and also Postgres (except for product attributes in some setups, for which there is an open bug report).
I am not sure we need to change all db_query() calls, it is not deprecated in D7, and the documentation even says:
Many SELECTs in Ubercart are simple query strings.
Can you give more detail about the errors you are getting when using the Oracle driver?
Comment #2
Sagar Ramgade CreditAttribution: Sagar Ramgade commentedHi,
When i enable uc_attributes module, error mentioned below started appearing :
PDOException: SELECT upa.aid FROM {uc_product_attributes} AS upa LEFT JOIN {uc_attributes} AS ua ON upa.aid = ua.aid WHERE upa.nid = :nid ORDER BY upa.ordering, ua.name (prepared: SELECT upa.aid FROM "EDABBA_"."UC_PRODUCT_ATTRIBUTES" AS upa LEFT JOIN "EDABBA_"."UC_ATTRIBUTES" AS ua ON upa.aid = ua.aid WHERE upa.nid = :nid ORDER BY upa.ordering, ua.name ) e: SQLSTATE[HY000]: General error: 933 OCIStmtExecute: ORA-00933: SQL command not properly ended (/tmp/PDO_OCI-1.0/oci_statement.c:142) args: Array ( [:nid] => 1 ) in uc_product_get_attributes() (line 1154 of ../public_html/sites/all/modules/contrib/ubercart/uc_attribute/uc_attribute.module).
Comment #3
TR CreditAttribution: TR commentedSupport for other databases is provided by the core Drupal Database API and contributed database driver modules like http://drupal.org/project/oracle. There is nothing inherently wrong about using db_query(), and in fact it is *recommended* for most select queries. However, there might be some complicated queries in Ubercart where the syntax used in the SQL isn't recognized by Oracle. It's also possible that either core Drupal or the Oracle driver are doing the wrong thing.
Looking through the issues on drupal.org, it seems that Oracle might require a different syntax for the ORDER BY clause. If you can let us know what the syntax should be for Oracle, then we could look through the code and modify and queries that use ORDER BY.
Because db_select() is significantly slower than db_query(), we'd like to avoid changing queries unless they have a specific identifiable problem.
Comment #4
longwavePerhaps the same as #1340360: from table AS alias - if you remove the "AS" before the table aliases, does that fix it without having to rewrite the query entirely?
Comment #5
TR CreditAttribution: TR commented@Sagar Ramgade: Have you made any progress on this?
Comment #6
Sagar Ramgade CreditAttribution: Sagar Ramgade commentedHi Tim,
Yes i figured it out, as oracle doesn't support "AS" keyword it was throwing errors. So i modified most of the queries in the module to make it work.
Comment #7
longwaveCould you post your changes as a patch file?
Comment #8
Sagar Ramgade CreditAttribution: Sagar Ramgade commentedHi,
Yes i will be posting a patch file soon as i am still in process of testing all of the submodules too.
Comment #9
longwaveBetter title, and back to active as we know what the problem is.
Comment #10
longwave@Sagar Ramgade: Can you test the attached patch? This should remove AS for table aliases across all modules in Ubercart.
Comment #11
longwaveManually tested the pages with queries that were changed in the above patch, all seems fine, so committed.