Cannot change the type of a column using vardefs #3865

Open
opened 2026-02-20 16:10:48 -05:00 by deekerman · 0 comments
Owner

Originally created by @connorshea on GitHub (Jul 25, 2019).

Issue

We added a field to AOS_Quotes a while back and it's supposed to represent 'sales total', aka the dollar amount for a given Order. However, it was stored with the type varchar(256). All of the values in the database are floats represented as strings, so it should (probably?) be possible to convert it to a float.

I tried changing custom/Extension/modules/AOS_Quotes/Ext/Vardefs/sugarfield_salestotal_c.php:

<?php
$dictionary['AOS_Quotes']['fields']['salestotal_c']['inline_edit']='1';
$dictionary['AOS_Quotes']['fields']['salestotal_c']['labelValue']='Sales Total';
$dictionary['AOS_Quotes']['fields']['salestotal_c']['type']='float';

But adding the type doesn't seem to do anything.

I also tried changing it to text, which should definitely be compatible, but that didn't do anything either.

Expected Behavior

The column would become a float.

Actual Behavior

The column remained varchar(256).

Possible Fix

I'm guessing either this isn't actually supported, or the code doesn't work quite right.

Steps to Reproduce

  1. Create a new field for AOS_Quotes (or any module, presumably) that's a varchar(256)
  2. Run the repair, use the field, etc.
  3. Change the type in the sugarfield_fieldname_c.php file.
  4. Run a Quick Repair and Rebuild
  5. The type will not change in the database.

Context

I'm not able to change a field from varchar(256) to float, which means we're storing dollar amounts as a varchar instead of a number.

Your Environment

  • SuiteCRM Version used: 7.9.17
  • Environment name and version (e.g. MySQL, PHP 7): PHP 7.2, MySQL 5.7
  • Operating System and version (e.g Ubuntu 16.04): macOS Mojave (10.14.6)
Originally created by @connorshea on GitHub (Jul 25, 2019). #### Issue We added a field to AOS_Quotes a while back and it's supposed to represent 'sales total', aka the dollar amount for a given Order. However, it was stored with the type `varchar(256)`. All of the values in the database are floats represented as strings, so it should (probably?) be possible to convert it to a float. I tried changing `custom/Extension/modules/AOS_Quotes/Ext/Vardefs/sugarfield_salestotal_c.php`: ```php <?php $dictionary['AOS_Quotes']['fields']['salestotal_c']['inline_edit']='1'; $dictionary['AOS_Quotes']['fields']['salestotal_c']['labelValue']='Sales Total'; $dictionary['AOS_Quotes']['fields']['salestotal_c']['type']='float'; ``` But adding the type doesn't seem to do anything. I also tried changing it to `text`, which should definitely be compatible, but that didn't do anything either. #### Expected Behavior The column would become a float. #### Actual Behavior The column remained varchar(256). #### Possible Fix I'm guessing either this isn't actually supported, or the code doesn't work quite right. #### Steps to Reproduce 1. Create a new field for AOS_Quotes (or any module, presumably) that's a varchar(256) 2. Run the repair, use the field, etc. 3. Change the type in the `sugarfield_fieldname_c.php` file. 4. Run a Quick Repair and Rebuild 5. The type will not change in the database. #### Context I'm not able to change a field from varchar(256) to float, which means we're storing dollar amounts as a varchar instead of a number. #### Your Environment * SuiteCRM Version used: 7.9.17 * Environment name and version (e.g. MySQL, PHP 7): PHP 7.2, MySQL 5.7 * Operating System and version (e.g Ubuntu 16.04): macOS Mojave (10.14.6)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#3865
No description provided.