The gid column is declared as an integer in all database schemas within og.install with one exception: In function og_field_schema, line 363, the gid column is declared as a float. On runtime this can lead to the following error when trying to create more than one group, at least when drupal is used in conjunction with an sqlite database:

Notice: Undefined index: 1.0 in og_label() (line 2222 of /tmp/drupal-7.8/sites/all/modules/og/og.module).
Exception: Group membership for entity user with ID 1 for group ID 1.0 () already exists. in og_membership_create() (line 1028 of /tmp/drupal-7.8/sites/all/modules/og/og.module).
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

znerol’s picture

Title: Data type in og_field_schema is float instead of int, results in sqlite errors » Data type of gid column in og_field_schema is float instead of int, results in sqlite errors
FileSize
628 bytes

Attached the trivial patch. I have no idea though of how to write an update-function which alters all the field data and revision tables...

amitaibu’s picture

We have a big problem with this -- #937442: Field type modules cannot maintain their field schema (field type schema change C(R)UD is needed). However, very soon OG will not use the data from the group-audience field. In fact there's already a work in progress (almost finished actually) to only use the OG membersihp entity.

Can you please try with this branch (don't forget to backup and execute update.php):
git clone --branch deprecate-audience http://git.drupal.org/project/og.git

znerol’s picture

I can confirm that the deprecate-audience branch does not have this specific problem when run with sqlite.

barraponto’s picture

This should be highlighted in the module page, to have people patching the module before using it with sqlite. It is a known issue we are postponing after all.
Or maybe fixing this and providing a "regression patch" for anyone already using sqlite with OG — very unlikely, since it prevents adding two groups ...

barraponto’s picture

Status: Active » Needs review

There is a patch and it works for new installs.
What we're reviewing is whether it makes sense to fix it for sqlite.

amitaibu’s picture

Status: Needs review » Needs work

We can fix it via an upgrade path, which should be added on top of the patch in #1

citlacom’s picture

Status: Needs work » Needs review
FileSize
6.64 KB

I had this same issue but affecting with fatal error in MSSQL DB engine in Windows environment for an installation that already have a lot of content types using group_audience fields and with many existing nodes so I prepared a patch that look for all that fields and convert it to the correct int type.

This issue is directly related with #1659078: MSSQL server error: Conversion failed when converting the nvarchar value '1.0' to data type int when access user profile and #1228300: Subgroup cannot be created with MSSQL

Status: Needs review » Needs work

The last submitted patch, OG-Fix-the-group-audience-float-schema-issue-1277842.patch, failed testing.

weboide’s picture

With version 7.x-1.5, I faced this same issue this morning and was thinking that my code was wrong for hours...
Is there a reason why we wouldn't be able to do a patch similar to what citlacom suggested?

amitaibu’s picture

> Is there a reason why we wouldn't be able to do a patch similar to what citlacom suggested?

There's no problem, but tests should at least pass before I review it :)

BassistJimmyJam’s picture

Title: Data type of gid column in og_field_schema is float instead of int, results in sqlite errors » Data type of gid column in og_field_schema is float instead of int
Status: Needs work » Needs review
FileSize
1.23 KB

I just encountered a floating point precision issue in MySQL due to this (specific gid is 1007508). See below:

mysql> SELECT * FROM field_data_group_audience WHERE group_audience_gid = 1007508;
+------------------+-----------------+---------+-----------+-------------+----------+-------+--------------------+----------------------+------------------------+
| entity_type      | bundle          | deleted | entity_id | revision_id | language | delta | group_audience_gid | group_audience_state | group_audience_created |
+------------------+-----------------+---------+-----------+-------------+----------+-------+--------------------+----------------------+------------------------+
| commerce_order   | commerce_order  |       0 |   1178538 |     4616928 | und      |     0 |            1007510 | 1                    |             1371592211 |
| commerce_order   | commerce_order  |       0 |   1178598 |     4626518 | und      |     0 |            1007510 | 1                    |             1371657220 |
| commerce_product | product         |       0 |    106078 |      124178 | und      |     0 |            1007510 | 1                    |             1371590295 |
| node             | product_display |       0 |    233568 |      233568 | und      |     0 |            1007510 | 1                    |             1371590295 |
| user             | user            |       0 |     79778 |       79778 | und      |   177 |            1007510 | 1                    |             1371504801 |
+------------------+-----------------+---------+-----------+-------------+----------+-------+--------------------+----------------------+------------------------+
5 rows in set (0.02 sec)

I've attached an updated patch.

Status: Needs review » Needs work

The last submitted patch, group-audience-gid-float-1277842-11.patch, failed testing.

BassistJimmyJam’s picture

Status: Needs work » Needs review
BassistJimmyJam’s picture

I realize that OG 2.x has been released and this may not be an issue there, but this is a pretty serious issue for sites still using 1.x that have gids which happen to correspond to floating-point issues in MySQL. Can we get some movement on this?