Quantcast
Channel: Recent posts across whole site
Viewing all articles
Browse latest Browse all 49206

Oracle support and O.R.M.

$
0
0

Hi all,
i'am one of the guys who is triyng to build an oracle driver for drupal.... (http://drupal.org/project/oracle)
I actually wrote 2 drivers: 1 for the 6.x and 1 for the 7.x. Both based on PDO_OCI, and both working pretty
well with the core, (i'am still working on the 7.x SimpleTest test cases but 90% is ok).

I started using the 6.x driver in production on February (when it was on sourceforge.net as drupaloracle).

A couple of days a go, one of my company web developers, told me:

"Hey.. we should use this X module.... It is cool!"

I installed it, but unfortunately, there are some queries inside that are really far from working on Oracle.

Like this query:

SELECT q.*, COUNT(s.sqid) AS subqueues FROM {nodequeue_queue} q LEFT
JOIN {nodequeue_subqueue} s ON q.qid = s.qid WHERE q.qid IN
($placeholders) GROUP BY q.qid

The meaning of this query in MySQL is somenthing like:

       Outer join "s" table to "q" table returning all "q" columns
        toghether with the count of child rows on "s" table

(grouped by the reference key)
.. where clause..

...the same query can be expressed in oracle in this way:

select q.*, (select count(s.sqid) from {nodequeue_subqueue} s where
q.qid = s.qid) as subqueues from {nodequeue_queue} q where q.qid in
($placeholders)

..the result is exactly the same, but the concept is very different:

    select all columns from "q" table and for each row query the

"s" table to count
the child records.... where clause...

I do not see a straight way to translate the first in the second query
without using a good SQL Parser... This is one of the cases where ONE (or precisely ME)
would like to have an O.R.M. so that module developers do not have
access to SQL code.

I think is absolutely normal and "good" that module developers focus on their
module business logic, not on the "ANSIness" of their SQL.. Mostly they use
MySQL.. They create great modules... That i cannot use on Oracle, so:

1) You may think: "ok, well, use mysql, stop trying making stupid things like drupal/oracle"

2) Let's find a suitable solution.

My questions are:

1) do we really expect to be portable?

2) do we really expect module developer that have access to SQL to write ANSI-SQL?

3) What about using a complete abstraction like http://en.wikipedia.org/wiki/Object-relational_mapping or similar?

WDYT??

Thanks,
Andrea

ps: actually i end up using an "exception query translator" for the moment, so that if a module query take an exception
you have a chance to translate it in your settings.php.


Viewing all articles
Browse latest Browse all 49206

Trending Articles