'Cos then how do you override it? This patch moves the simpletest_like_tables to db_get_like_tables, to the DB layer where it belongs. Untested but I need Crell's eyes on this ASAP as it blocks SQLite.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Help if I roll a complete patch.

Crell’s picture

Status: Needs review » Needs work

This looks like a good approach for now. Schema introspection belongs in the schema system. We'll get around to rewriting Schema API later. :-)

So +1 on the approach, but -1 on the current code. It's still highly buggy just from visual inspection, Like, variables used without being defined. Bad chx!

Damien Tournoud’s picture

I would also argue that the "remove the tables that are in the schema" part should go away too.

chx’s picture

Priority: Normal » Critical
Status: Needs work » Reviewed & tested by the community
FileSize
3.61 KB

As Crell liked it and now works I dare to say it's RTBC. What Damien asks is a next patch. I bumped this to critical as it holds up SQLite.

Damien Tournoud’s picture

Status: Reviewed & tested by the community » Needs work

Sorry chx,

- getLikeTables() is badly indented
- its PHPDoc is not consistent with its behavior (in the current implementation, tables that are in the schema are not returned).

chx’s picture

Status: Needs work » Needs review
FileSize
3.62 KB

Fixed both.

chx’s picture

Very nice tip from DamZ (fetchAllKeyed(0,0) ) made the simpletest code nicer and the result more useful and simpler.

Damien Tournoud’s picture

Status: Needs review » Reviewed & tested by the community

Good enough for me.

chx’s picture

Dropped $target after a discussion -- it would nto be different for different targets. We tried to add different databases but then schema API as it is does not support yet. Let's not overdo it.

mfer’s picture

Damien Tournoud said his RTBC still stands and I agree.

There is an unrelated error that came up while running the tests (on the next page load) which reads something like "Warning: call_user_func_array(): First argument is expected to be a valid callback, 'database_test_query_alter' was given in drupal_alter() (line 2896 of /Users/mfarina/workspace/drupal/includes/common.inc)." But, this comes up on a clean copy of head and isn't related to this patch.

All database tests pass after this patch.

Dries’s picture

Status: Reviewed & tested by the community » Needs work

The part that worries me about this patch, is that it might be permanent. As they say: "nothing is more permanent than a temporary solution".

I find the name of the function to be slightly odd. Also, "get_like_tables" exposes too much of the implementation. How about a more generic "search_tables" or somthing? Thoughts?

Crell’s picture

Permanent or temporary, something that needs to be different on different databases belongs in the driver classes.

Using "like" in the method/function name makes sense if that's the API it accepts, vis, it behaves like a LIKE query. If not, then it should be something else. findTablesLike() works if that's the input. findTablesBeginningWith() is probably too verbose. Hm.

chx’s picture

So people, what do we want to call the method that finds tables which begin with the name that is passed in?

chx’s picture

Status: Needs work » Needs review
FileSize
3.76 KB

So I renamed and generalized more based on a hasty IRC discussion. It's fairly nice now I think.

sun’s picture

Status: Needs review » Needs work

Wrong indendation:

+/**
+  * Find all tables that are like the specified base table name.
+  *

Quote the example value?

+  *   An SQL expression, for example simpletest% . BEWARE: this is not

Double return:

+
+

Wrong indentation (different!):

+  /**
+   * Find all tables that are like the specified base table name.
+   *
+  * @param table_expression
+  *   An SQL expression, for example simpletest% . BEWARE: this is not
+  *   prefixed, the caller should take care of that.
+   * @return
+   *   Array, both the keys and the values are the matching tables.
chx’s picture

Status: Needs work » Needs review
FileSize
3.78 KB

Are you channeling webchick there? You sound awfully like her.

Damien Tournoud’s picture

Status: Needs review » Reviewed & tested by the community

That's even nicer than the previous one.

chx’s picture

FileSize
4.8 KB

Pffft system tests failed. (empty arrays are casted to FALSE and nonempty are casted to TRUE by assertTrue/False.)

Damien Tournoud’s picture

This patch is cursed :)

I just confirmed that the whole suite passes now. Keeping the status.

hswong3i’s picture

Sorry for get into this issue late. Maybe we want all tables retrieved and then process those?

chx’s picture

Getting all tables is not what this issue is about. You want #301038: Add a cross-compatible database schema introspection API instead. The problem here is, I do not want to retrieve all and then have PHP pour over them.

hswong3i’s picture

Get it. Just subscript that issue and will move focus to there.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Excellent. Much better, and a lot closer to what I had in mind. Thanks for following through and not giving up on me. ;-)

Committed to CVS HEAD.

sun’s picture

Status: Fixed » Reviewed & tested by the community
FileSize
1.24 KB

meh! @chx: Go fix your editor!

Note to self: Don't go to sleep when chx drives people nuts for getting a patch in.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Also, the PHPDoc comments for db_find_tables() and findTables() needs to match; additionally, it should be param $table_expression, not param table_expression.

Nice job channeling me otherwise, though! I appreciate it. :D

sun’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
1.94 KB

Nice catches. ;)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed! :)

c960657’s picture

It looks like this caused a regression in system.test: #328719: Module list functionality test fails

Anonymous’s picture

Status: Fixed » Closed (fixed)

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