We use views on Oracle and we would like to include an 'oracle' case for random sorts in the handlers/views_handler_sort_random.inc.
A little patch to add this case is attached.

CommentFileSizeAuthor
sort_random_oracle.patch482 bytesaaaristo

Comments

dawehner’s picture

Version: 6.x-2.0 » 6.x-2.x-dev
Status: Active » Needs review

Update status.

I fear noone can test this, so reviewing the code is hard. Does views in general works with oracle.

merlinofchaos’s picture

Title: RANDOM ORDER BY FOR ORACLE » Random order by for Oracle

Please don't shout in issue titles.

merlinofchaos’s picture

Status: Needs review » Closed (won't fix)

Drupal core includes no built in support for Oracle.

My feeling is that whatever provides oracle support and drivers should use hook_views_data_alter() to create its own handlers. This will be much better for Oracle since the people responsible for the driver will have more knowledge and ability to react to problems.

aaaristo’s picture

I started looking at the hook_views_data_alter() and it seems that you are suggesting to rewrite things like the sort handler and the date_sql (other issue http://drupal.org/node/759276) handler from scratch... Right? I can surely do that but looks like a lot more code to maintain...

"Drupal core includes no built in support for Oracle."
Of course, but now there is a project to support it: http://drupal.org/project/oracle, and Views module is actually working well on Oracle: those patches are only little fixes to very specific problems that are specifically handled (by Views) in different ways for different database types.. So, may maybe you can include those pieces of code and i can help maintain it. Let me know.

aaaristo’s picture

Status: Closed (won't fix) » Active

Sorry, reopened to discuss further...

dawehner’s picture

Nor views 3.x or views 2.x uses dbtng, only views 3.x for drupal7.

Orcacle uses dbtng

merlinofchaos’s picture

I can surely do that but looks like a lot more code to maintain...

Perhaps this is not what you intended, but "There's a lot of code to maintain. You do it, I don't want to" does not sway my thinking.

Views' policy is quite particular about its support for contrib. It is designed to be pluggable and overridable and there are a few exceptions to that but in general, these overrides can be done by the module. As a result, it is very rare that I'll accept patches specific to a module, which this is.

So yes, making a subclass inheriting the random sort handler for Oracle specific behavior might require 'maintaining' that code (though history suggests it changes very very rarely) so there isn't really any more maintenance work for you than there is for me. And what I mean is that, I don't run Oracle, I don't have Oracle, so I can't test Oracle patches. I can't respond to problems people have with the Oracle implementation, and I don't want to respond to problems people have with the Oracle implementation. That needs to happen by the people who are writing and maintaining the Oracle implementation.

Also, on closer inspection, the actual code to maintain will be:

1) A subclass of the random sort handler specific to oracle that overrides the formula used in the query() method. Perhaps this would be less code if the formula used were moved to a constructor or something.
2) The appropriate hook_views_handlers() code to declare the handler
3) The appropriate hook_views_data_alter() code to place this handler in place of the original.

It doesn't have to care what the formula for mysql is or changes to because Drupal 6 does not support multiple db types in the same install. So it sticks its own formula in for the query -- that's probably 10-15 lines of code, including structure and closing braces, and doxygen comments.

Now, where I'll listen are where you can come up with patches to Views that makes your job easier. If you can find an easy way to do the overrides with a little less code, great! So maybe there's a way to reorganize the handler. More likely, there's going to be something else (date manipulation I'll wager) that needs oracle specific behavior. Perhaps I'll need to provide some kind of hook or something. I'm open to things like that. Those will allow you to do your job more effectively.

aaaristo’s picture

@dereien: No we are used by dbtng we do not use dbtng when oracle is the backend for drupal.

aaaristo’s picture

I was not trying to get you doing my job:

"So, may maybe you can include those pieces of code and i can help maintain it"...

Don't mind i'll write the hooks...

aaaristo’s picture

When you say "module" you mean a drupal module or a view module in the modules directory of views?

Can i implement a module with the hooks you suggested like a view module? Because the "Oracle driver" is not
a module actually but a drupal backend... So there is actually no .module to handle hook implementations...

Where can i find some doc on how to use hook_views_data_alter() to replace an handler?

dawehner’s picture

He definitive means a extra contrib module. You can definitive add a module in your package and write something into your INSTALL.txt. that you need this module for oracle and views.

Every documentation is in help directory included into views. There are some contrib modules out there, which replaces the handler of something else.
One example is http://drupal.org/project/views_taxonomy_selective_filter

"So, may maybe you can include those pieces of code and i can help maintain it"...

Views is already such big, every thing which is not a "implementation" of drupal core, should be moved out.

merlinofchaos’s picture

I would think that maybe there needs to be an oracle_views module that is packaged with the oracle driver backend, then.

aaaristo’s picture

Status: Active » Closed (fixed)

I'm closing the issue because i'm writing an oracle_views module to implement the hooks

aaaristo’s picture

Status: Closed (fixed) » Active

Are you going to provide a solution like this http://drupal.org/node/858118 also for this issue ?

dawehner’s picture

I don't see a total reason for doing this, as you can override the handler already at the moment.

dawehner’s picture

Status: Active » Fixed

VIews2 is in a only critical bug fixes only state, so this will not going to happen.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.