CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Bug: Custom Data Fields - Similar field labels cause error (fixed in 2.1)
Pages: [1]

Author Topic: Bug: Custom Data Fields - Similar field labels cause error (fixed in 2.1)  (Read 1740 times)

ansm

  • Guest
Bug: Custom Data Fields - Similar field labels cause error (fixed in 2.1)
June 11, 2008, 10:05:08 am
Hello,
I just installed CiviCRM with Drupal.  It looks like a great system, especially for 2.1.  However I've run into many bugs already.  First of all, is there a better place to report them - I haven't found a bugtracker.
So for now, here's the bug. 
CiviCRM 2.04 w/ Drupal 5.7.  I'm at Home » CiviCRM » Administer CiviCRM » Custom Data.
I'm adding a custom field.  I want to ask a question: "How many volunteers has your organization involved in 2006?".  That works ok.  Now I add a field: "How many volunteers has your organization involved in 2007?" and I get a duplicate column name error.  This is because, the custom data is put into the DB as a transformation of the Field Label, specifically, the first 32 characters, with underscore substituted for space, and any illegal column name characters removed, as the field name.
This is a simple and logical way of creating a column name however, it means I get a "collision" when I ask my second question.
For users, the workaround is to make some small change to the question within the first 32 characters, however this doesn't really help, as there's no good change that I like.
Logically, the field label name should be completely freely chosen, and it is, the only problem it's used to derive an internal fieldname. 
To programmers: I might suggest adding an 8 digit random number at the end - should problistically eliminate this problem, and it's a very quick fix, which I hope can make it into 2.1!
Of course, to do this properly you need to check for duplicates and try once more.  The only real way to solve it is to have a guaranteed unique function.  Is there a way to do this without storing an ordered list?  Note to self, check The Art of Programming.
« Last Edit: June 12, 2008, 06:48:40 am by ansm »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Custom Data Fields - Bug
June 11, 2008, 11:31:11 am

So we add the custom field id to the custom name (line 970 in CRM/Custom/Form/Field.php). This should prevent name conflicts even if the fields have got the same name upto 32 characters. Can you please reproduce this on our demo machine: http://drupal.demo.civicrm.org/ and we'll fix it

The bug tracker is at: http://issues.civicrm.org/. Please discuss issues in the forum and once reproducible etc, we'll ask you to file an issue

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

ansm

  • Guest
Re: Custom Data Fields - Bug
June 11, 2008, 11:47:42 am
Thanks for the quick response.  I did exactly as you suggested.  I simply added a custom field, with two similiar questions.  I can confirm that the same error message occurred on your live demo system.

-----------------------------------
Constituent Information - Custom Fields

unrecoverable error
    Sorry. A non-recoverable error has occurred.

    DB Error: unknown error

    Database Error Code: Duplicate column name 'trying_to_create_a_fieldname_con', 1060

    Return to home page.

Error Details:

Array
(
    [callback] => Array
        (
           
  • => CRM_Core_Error
  • [1] => handle
            )

       
Code: [Select]
=> -1
    [message] => DB Error: unknown error
    [mode] => 16
    [debug_info] =>         ALTER TABLE civicrm_value_1_constituent_information
        ADD COLUMN `trying_to_create_a_fieldname_con` varchar(255) [nativecode=1060 ** Duplicate column name 'trying_to_create_a_fieldname_con']
    [type] => DB_Error
    [user_info] =>         ALTER TABLE civicrm_value_1_constituent_information
        ADD COLUMN `trying_to_create_a_fieldname_con` varchar(255) [nativecode=1060 ** Duplicate column name 'trying_to_create_a_fieldname_con']
    [to_string] => [db_error: message="DB Error: unknown error" code=-1 mode=callback callback=CRM_Core_Error::handle prefix="" info="        ALTER TABLE civicrm_value_1_constituent_information
        ADD COLUMN `trying_to_create_a_fieldname_con` varchar(255) [nativecode=1060 ** Duplicate column name 'trying_to_create_a_fieldname_con']"]
)
---------------------------------
Existing field label: Trying to create a fieldname conflict in 2007
Tried to add this field label: Trying to create a fieldname conflict in 2008
resulting in above failure.

Thanks again.  Now do I enter it in the bugtracker?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Custom Data Fields - Bug (similar field labels cause error)(confirmed)
June 11, 2008, 12:13:48 pm

Oops. This has been fixed in trunk (which will become 2.1). You can verify by checking it on: http://sandbox.civicrm.org/

apologies for pointing u in a wrong direction.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

ansm

  • Guest
Re: Custom Data Fields - Bug (similar field labels cause error)(confirmed)
June 12, 2008, 06:47:38 am
Thanks.  I've confirmed on Sandbox that this error is fixed in 2.1.  However, there is another error in the same code, so don't forget where you looked and see my separate message: Bug: Custom Data Fields-Field Label Starts with Number (confirmed).

vtitarchuk

  • I’m new here
  • *
  • Posts: 16
  • Karma: 1
  • Expert in Development of Educational Technologies
    • ServanTek Ukraine
  • CiviCRM version: 4.1
  • CMS version: Drupal
Re: Bug: Custom Data Fields - Similar field labels cause error (fixed in 2.1)
July 08, 2008, 12:12:08 am
I have checked the sandbox with my errors that are similar. It seems to be working. However, I need to fix this error in 2.0.1. How do I upgrade the trunk that deals with this issue?

I have two clients that are using the software already, so I need the solution now. However, I would be glad to know when 2.1 will come out.
Customizing CiviCRM for non-profits is the former Soviet Union
Localizing CiviCRM into Russian
Deploying CiviCRM in multi-lingual and multi-organizational environments
http://servantek.org.ua

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Bug: Custom Data Fields - Similar field labels cause error (fixed in 2.1)

This forum was archived on 2017-11-26.