Hello. when i get error in edit geo field setting with openlayer i find this issue and i unistall my geofield 7.1.1 and install geofiled-7.x-1.x-dev. And when i want create new geofield (with each widget) i get this error and redirect to admin/structure/types/manage/mycontenttype/fields

There was a problem creating field myfieldlabel: SQLSTATE[42000]: Syntax error or access violation: 1101 BLOB/TEXT column 'field_myfield_srid' can't have a default value
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drupalion’s picture

resolved problem with update to geofiled-7.x-2.x-dev

guillaumev’s picture

Status: Active » Needs review
FileSize
1.88 KB

Note that this problem is caused by http://drupal.org/node/1942826. Here is a patch which fixes and adds an update function for existing fields, update function which had not been added in http://drupal.org/node/1942826.

larowlan’s picture

Status: Needs review » Needs work

This throws an erro

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the  [error]
right syntax to use near 'FROM 
field_data_field_coordinates f' at line 1
larowlan’s picture

Status: Needs work » Needs review
FileSize
1.88 KB
656 bytes

Patch at #2 has incorrect use of SelectQuery::fields method
Fix attached.

guillaumev’s picture

Thanks for fixing my patch :-) ! Here is a new one which fixes a warning that shows when there is no content to update... (through a if (!empty($values)) ).

LeDucDuBleuet’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that patch in #5 is working properly.
Thank you very much! :-)

radimklaska’s picture

#5 worked for me. Thanks!

Brandonian’s picture

Status: Reviewed & tested by the community » Fixed

#5 committed to both 1.x and 2.x branches. Thanks, @larowlan and @guillaumev!

7.x-1.x - http://drupalcode.org/project/geofield.git/commit/1756445
7.x-2.x - http://drupalcode.org/project/geofield.git/commit/599ec51

mraichelson’s picture

Still coming across this error when trying to update a site from 7.x-1.1 to latest 7.x-2.x-dev here.

mraichelson’s picture

Status: Fixed » Active

After a bit of poking around: commenting out geofield_update_7100() clears up this issue when trying to upgrade.

Since 7100 changes the field type of the srid field which seems to be what's freaking out (at least for me) and then 7202 eliminates it as a field entirely can 7100 be removed?

(Glad to put together a patch, just want to double-check on what's doing what.)

grota’s picture

Yeah, I can confirm the upgrade path is broken because of geofield_update_7100(), deleting it fixes the problem

TwoD’s picture

Update 7100 does exactly what a schema update MUST NOT do, it reuses the CURRENT schema definition in an old update.

If you try to update from an early 7.x-1.x state to a late 7.x-2.x, the schema will have changed drastically. You MUST copy the old schema (or the relevant parts of it) into the update functions or the result becomes very unpredictable. In my case, I had to extract the old schema from a 7.x-1.x version and remove the $schema = geofield_field_schema(array()); line and use this instead:

$schema =  array(
    'columns' => array(
      'srid' => array(
        'type' => 'text',
        'not null' => FALSE,
      ),
  );
thelee’s picture

Priority: Normal » Major

TwoD in #12 is exactly right - this issue completely broke down one of our sites. there's a slight typo in his code, though, should be (missing a paren):

$schema =  array(
    'columns' => array(
      'srid' => array(
        'type' => 'text',
        'not null' => FALSE,
      ),
  ),
);

can anyone more knowledgeable comment if simply swapping out the schema line with this is a sufficient change for a patch? that's what I did and it got our site/update working fine again, but don't know if this would lead to unintentional side effects.

Christopher Riley’s picture

Yes this resolved the issue that I had doing the upgrade to the latest dev version.

SocialNicheGuru’s picture

The above fix in 13 worked.

Otherwise I get the following:

drush updatedb
The following updates are pending:

geofield module :
7100 - Changing srid from int to text
7200 - Change geofield lat, lon, left, top, right and bottom from floats to numeric fields with precision of 18 and scale of 12.
7201 - Converts the wkt field into a geom field. Converts already existing data from wkt storage to wkb. Much inspiration for this implementation comes from taxonomy_update_7005.
7202 - Drops unused table fields srid, accuracy and source, adds geohash field, populates it.

Do you wish to run all pending updates? (y/n): y
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server[error]
version for the right syntax to use near 'DEFAULT NULL' at line 1
Finished performing updates.

Brandonian’s picture

Status: Active » Fixed

Good catch, @TwoD and @thelee. Apologies for taking a bit to fix this, but I've committed a change to the original update hook based on @TwoD's comments in 13.

http://drupalcode.org/project/geofield.git/commit/fce2c4f

Status: Fixed » Closed (fixed)

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

Jan van Diepen’s picture

Issue summary: View changes
FileSize
540 bytes

I'm upgrading from 7.x-1.0 to 7.x-2.1 and am having the issue described in https://drupal.org/node/2057485:

drush updb -y
The following updates are pending:

geofield module : 
  7100 -   Changing srid from int to text 
  7200 -   Change geofield lat, lon, left, top, right and bottom from floats to numeric  fields with precision of 18 and scale of 12. 
  7201 -   Converts the wkt field into a geom field. Converts already existing data from wkt storage to wkb.   Much inspiration for this implementation comes from taxonomy_update_7005. 
  7202 -   Drops unused table fields srid, accuracy and source, adds   geohash field, populates it. 

Do you wish to run all pending updates? (y/n): y
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'f.field_actionitem_lat_long_srid' in 'field list'                                                                            [error]
Performed update: geofield_update_7100                                                                                                                                               [ok]
Finished performing updates.                                                                                                                                                         [ok]

In case the table to be updated has no entries the following lines of code in geofield_update_7100()

$values = db_select($table_name, 'f')
  ->fields('f', array($column_name, 'entity_type', 'bundle', 'entity_id'))
  ->execute()
  ->fetchAssoc();

returns a non-empty object.

Changing the conditional statement two lines down the code from
if (!empty($values)) {
to
if (!empty($values) && (count($values) > 0)) {
solved it for me.

Attached is a patch against the current 7.x-2.x branch.

Jan van Diepen’s picture

Status: Closed (fixed) » Needs review