Hi,
this is a very nice module. Just the thing i needed.

But there seems to be a problem either with the "node_composite" schema or the "composite_update()" function regarding the "INSERT" query.

The "node_composite" schema defindes the field "data" to be "not NULL" without defining a default value, but the "INSERT query never inserts anything into the field. As far as i've been told, most modern databases provide 'NULL" as the default value for fields having the constrain "not NULL" regardeless of the type of the field (missing the definition of a default value).

Error message on Drupal 6.6 using MySQL 5.0.51b, PHP 5.2.5, Apache 2.2.6 (all on Windows XP SP2):

Field 'data' doesn't have a default value query: INSERT INTO node_composite (nid, vid, layout) VALUES (15, 15, 'onecol') in [...]\sites\all\modules\composite\composite.module on line 421.

I could fix this localy by chaniging line 421 to:

db_query("INSERT INTO {node_composite} (nid, vid, layout, data) VALUES (%d, %d, '%s', '%s') ", $node->nid, $node->vid, $node->composite_layout, '');

But i'm not sure if the empty string is the suggested default value.

Comments

bengtan’s picture

Assigned: Unassigned » bengtan

Hi,

The column node_composite.data isn't currently used, and it was added as an afterthought for future expansion. Evidently, the code didn't get updated afterwards for this new column.

The change you've suggested is a suitable fix.

Now, I've noticed you've flagged this issue as critical. Is it causing a big problem for you?

I'd rather not rush out a new release just for this one thing, but if it is critical for you, then let me know.

Also, good catch. Thanks for this.

testosterone_z’s picture

Well, critical insofar as the module won't work without a fix, because every "INSERT INTO {node_composite}" will fail with "violates not-null constraint" on recent databases (tested at least on MySQL 5.0.51b and PostgreSQL 8.2).

Maybe the database scheme for "node_composite" in "composite.install" needs to be updated with an explicit default value for the field "data", e.g:

'data' => array('type' => 'text', 'size' => 'medium', 'not null' => TRUE, 'serialize' => TRUE, 'default' => ''),

But again, a very, very, very usefull module. Thanks for this.

bengtan’s picture

Status: Active » Fixed

Hi, Composite Layout 6.x-1.0beta2 has been released which fixes this. Please give it a try. Thank you.

testosterone_z’s picture

Version: 6.x-1.0-beta1 » 6.x-1.0-beta2
Status: Fixed » Active

I'm sorry, but it seems my suggestion for the db scheme fix doesn't work:

'data' => array('type' => 'text', 'size' => 'medium', 'not null' => TRUE, 'serialize' => TRUE, 'default' => '')

On installation drupal returns the error message:

BLOB/TEXT column 'data' can't have a default value query:
CREATE TABLE drupal6_node_composite ( `nid` INT unsigned NOT NULL DEFAULT 0, `vid` INT unsigned NOT NULL DEFAULT 0, `layout` VARCHAR(255) NOT NULL DEFAULT '', `data` MEDIUMTEXT NOT NULL DEFAULT '', PRIMARY KEY (vid), INDEX nid (nid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in [...]drupal\includes\database.inc on line 515.

So i think it's best to use the database scheme from version 1.0beta1 and insert the empty string in the queries.

bengtan’s picture

Just checked http://drupal.org/node/146939:

Note that type 'text' and 'blob' fields cannot have default values.

Who designed these databases?!

:)

Don't worry, I'm not blaming you. I'll roll out a beta3 then. Have a look out for it.

bengtan’s picture

Status: Active » Fixed

Presumed fixed.

Status: Fixed » Closed (fixed)

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