Sigh, Running D6 on PG, Installed the module, the first computed field I made:

    * warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "(" LINE 1: ...LE content_type_wxrecord ADD COLUMN field_test_value real(1) ^ in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\cms\includes\database.pgsql.inc on line 138.
    * user warning: query: ALTER TABLE content_type_wxrecord ADD COLUMN field_test_value real(1) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\cms\includes\database.pgsql.inc on line 688.

I really need this to work, how can I help?

Comments

spydmobile’s picture

based on info found here about PG datatypes:
http://www.postgresql.org/docs/7.4/interactive/datatype.html

I modified line 100 of computer_field.module to be this:
Line 100-: if (!($field['data_type'] == 'text' || $field['data_type'] == 'longtext')) {
Line 100+: if (!($field['data_type'] == 'text' || $field['data_type'] == 'longtext' || $field['data_type'] == 'int' || $field['data_type'] == 'float')) {

This was done with the intention to ignore the datatype length enforcement on integers and floats that was being enforced upon pgsql resulting in, for example, creating int(n) when this is clearly not how it is done in pgsql.

I dont know the effect this would have on other databases, but I would assume making this change to the module would probably break it for mysql . but for recent PGsql, this will at least get past the problems of making the table columns. I still have to test the rest of the functionality, but I can only assume, you could test for database type and if pgsql is in use, ignore float and int datatype lengths as a long term solution.

I will return and comment further if this moves this module into the usable class for pgsql

spydmobile’s picture

ok, one final change:
Line 88-:if (!($field['data_type'] == 'text' || $field['data_type'] == 'longtext') && empty($field['data_length'])) {
Line 88+:if (!($field['data_type'] == 'text' || $field['data_type'] == 'longtext' || $field['data_type'] == 'int' || $field['data_type'] == 'float') && empty($field['data_length'])) {

This is to confirm that the change rendered the module fully functional with the following caveats:

if you use this patch/change to the module for mysql it probably wont work.

Moonshine’s picture

Priority: Critical » Normal

I know I'm late to the party on this one, but I have a sneaky feeling this may go much deeper then Computed Field.

Computed Field just defines its db fields for CCK via the Schema API:

http://api.drupal.org/api/group/schemaapi/6

Which says it says:

'length': The maximal length of a type 'varchar' or 'text' field. Ignored for other field types.

So it sounds to me like it isn't being ignored for int and float fields on PG? I don't use PG, but maybe someone who does can poke around and see if Schema API might be at the root of this. If it is then we need to move this to the Drupal issue queue.

Moonshine’s picture

Status: Active » Closed (won't fix)

Marking this as won't fix as D7 in upon us with it's magical DBTNG. Hopefully Postgress will work fully, and if not I'll check it out.