This patch corrects what I think is a mistake on the filter table where the weight of a particular filter is keyed as a primary key.

I have corrected this to use the module as the primary key

CommentFileSizeAuthor
#3 drupal_4.4.0_filters_0.patch798 bytesLilDave
drupal_4.4.0_filters.patch798 bytesAnonymous (not verified)

Comments

Anonymous’s picture

dries’s picture

Shouldn't that be KEY module (module) instead of KEY weight (module)?

LilDave’s picture

StatusFileSize
new798 bytes

Yes it should be. Attached is corrected patch.

dries’s picture

Committed to HEAD. I updated database/updates.inc too. Thanks.

Steven’s picture

This was not a mistake: the filters are always fetched ordered by weight so it makes sense to key on weight, no? The .mysql and .pgsql were in sync before this patch afaik.

LilDave’s picture

If you put a unique index on the weight column you can only have 1 filter at any particular weight. Doing so kind of defeats the purpose of allowing multiple filters. More to the point, if you have this setting, unconfigured filters will insert themselves as weight 0 ... if you have any filter already installed at weight 0, the insert will fail as there is a unique key on the weight column.

If you need to have them come back in a specific order, add an order by clause the the relevant SQL with direction of ASC.

Steven’s picture

Yes but note that in the mysql version, 'weight' was not a unique, primary key, it was just a regular key. The PGSQL conversion contained a mistake then...

LilDave’s picture

Ok now I see what you're saying. Probably for clarity it should be an indexed column. When I think of 'KEY' I think UNIQUE as being synonymous.

Now not to quote scripture on this, but the MySQL database documentation indicates that from MySQL 4.1+, KEY is a synonym for PRIMARY KEY (which is forced NOT NULL, UNIQUE over all columns involved). In versions prior, INDEX and KEY were considered synonymous. The change in 4.1 was made such that MySQL would be more compatible with other DB systems.

So probably the best change would be to just create an INDEX on the columns you're after. INDEX would allow non-unique entries at that point.

In the interest of cross platform compatability (which seems to be lacking in a number of OTHER CMS systems), it's probably better to aim for the SQL standard rather than a specific databases implementation.

I personally am a PostgreSQL user (hence my posting this) and as far as I know, PostgreSQL is touted as one of the more SQL standard OSS engines. Just my .02$ ... take it or leave it. Just here to help.

killes@www.drop.org’s picture

Steven, did that get fixed?

Steven’s picture

I left it as is for now because the filters table was tiny anyway. In my upcoming filter patch I did take this into account though.

jonbob’s picture

Filter system is completely rewritten; this is obsolete.

Anonymous’s picture