Page 1 of 2

Error trying to clone an object

Posted: Mon Oct 19, 2020 9:33 pm
by n9yty
I am having a problem with cloning an object on a form. I have tried this with several objects, none clone.

1) I have an object open in the Object editor.
2) I hit the CLONE button
3) The top menu bar changes to just SAVE
4) I change the Label/ID/other information
5) I hit Save
6) It says "Record Saved" briefly, then the window loses all information in all fields and the header just says "Object >"
7) The object is not created

nuDebugLog shows:

[0] :
===USER==========

globeadmin

===PDO MESSAGE===

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `nubuilder`.`zzzzsys_object`.`sob_input_count` at row 1

===SQL===========

INSERT INTO zzzzsys_object (zzzzsys_object_id, `sob_all_table`, `sob_all_order`, `sob_all_zzzzsys_tab_id`, `sob_all_type`, `sob_all_label`, `sob_all_id`, `sob_all_top`, `sob_all_left`, `sob_all_width`, `sob_all_height`, `sob_all_cloneable`, `sob_all_align`, `sob_all_validate`, `sob_all_access`, `sob_all_zzzzsys_form_id`, `sob_run_zzzzsys_form_id`, `sob_run_filter`, `sob_run_id`, `sob_run_method`, `sob_display_sql`, `sob_select_sql`, `sob_select_multiple`, `sob_lookup_zzzzsys_form_id`, `sob_lookup_code`, `sob_lookup_table`, `sob_lookup_description`, `sob_lookup_description_width`, `sob_lookup_javascript`, `sob_subform_table`, `sob_subform_zzzzsys_form_id`, `sob_subform_foreign_key`, `sob_subform_add`, `sob_subform_delete`, `sob_subform_type`, `sob_image_zzzzsys_file_id`, `sob_input_format`, `sob_input_count`, `sob_input_type`, `sob_input_javascript`, `sob_html_code`, `sob_html_chart_type`, `sob_html_javascript`, `sob_html_title`, `sob_html_vertical_label`, `sob_html_horizontal_label`, `sob_calc_format`, `sob_calc_formula`) VALUES ('5f8de7ca8aa54fa', 'namf', '110', '5f8be8499ceedb9', 'display', 'Largest Gift Amount', 'big_gift_amount', '4', '200', '100', '20', '1', 'left', '0', '1', '5f8bd480b34bc7d', '', '', '', '', 'SELECT big_gift_amt
FROM prmf
WHERE id_code = #RECORD_ID#', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'D|mm-dd-yyyy', '', 'nuDate', '', '', '', '', '', '', '', '', '');

===BACK TRACE====

/Users/n9yty/Sites/nubuilder/nudata.php - line 386 (nuRunQuery)

/Users/n9yty/Sites/nubuilder/nuapi.php - line 51 (nuUpdateDatabase)

Re: Error trying to clone an object

Posted: Mon Oct 19, 2020 9:50 pm
by n9yty
I do see in the zzzzsys_object table that the object I am trying to clone, which was created from the "Form Object List" menu, as were most (all?) the fields on this form, has a NULL in the `sob_input_count` column. Many objects in the table do. But I see the ones created when I was troubleshooting my earlier problem, created using the FastForms Builder, have a 0 in this column. If I modify the table to put a 0 in there for the initial field, the clone works.

Re: Error trying to clone an object

Posted: Mon Oct 19, 2020 9:57 pm
by n9yty
I also note that for the objects I created manually have a lot of other columns with NULL that the FastForm objects do not seem to, they are blank, not NULL.

In fact, for the FastForm created objects, I don't see a single column with a NULL value, whereas there are many for the manually created objects.

For the field I just cloned (after changing the sob_input_count on the source object) the only NULL column is sob_lookup_autocomplete, all the other objects either have a value or are simply blank.

Re: Error trying to clone an object

Posted: Tue Oct 20, 2020 12:09 am
by Janusz
I also note that for the objects I created manually have a lot of other columns with NULL that the FastForm objects do not seem to, they are blank, not NULL.

In fact, for the FastForm created objects, I don't see a single column with a NULL value, whereas there are many for the manually created objects.
just to confirm I have the same behaviour.
if you want to allow object clone - so after manually created objects you need to change the sob_input_count and sob_all_order to 0.
or best to change default value in the mysql table to 0 using phpmyadmin or with code from below.

Code: Select all

ALTER TABLE `zzzzsys_object` CHANGE `sob_input_count` `sob_input_count` BIGINT(20) NULL DEFAULT '0';
ALTER TABLE `zzzzsys_object` CHANGE `sob_all_order` `sob_all_order` INT(11) NULL DEFAULT '0';
and all objects created after should be cloneable. Dont forget to make a DB back-up before.

Re: Error trying to clone an object

Posted: Tue Oct 20, 2020 5:39 am
by kev1n
I'm not getting any errors when cloning objects here.
All I see in phpMyAdmin, when I run your query manually, a Warning but not an Error.
Warning: #1366 Incorrect integer value: '' for column `nu6`.`zzzzsys_object`.`sob_input_count` at row 1
You guys probably have set sql_mode=strict

Also see this stackoverflow post:
It depends on the sql_mode you're running as. If the mode isn't strict then you'll get the inserted value to be the same as the coercion to that type,
https://dba.stackexchange.com/questions ... d-in-mysql

@Janusz: Nice fix. Should be included in nuBuilder! Added the Bug to my Bugtracker

Re: Error trying to clone an object

Posted: Tue Oct 20, 2020 6:02 am
by Janusz
Yes - I am keeping default MariaDB strict mode settings:

Code: Select all

MariaDB [(none)]> SHOW VARIABLES LIKE 'sql_mode';
+---------------+-------------------------------------------------------------------------------------------+
| Variable_name | Value                                                                                     |
+---------------+-------------------------------------------------------------------------------------------+
| sql_mode      | STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+---------------+-------------------------------------------------------------------------------------------+
1 row in set (0.002 sec)
https://stackoverflow.com/questions/384 ... or-mariadb
and like this explanation from above post:
Always use strict mode. That is, until you get fed up with its restrictions. The mode is there to help you, but it may be painful.

Re: Error trying to clone an object

Posted: Fri Oct 30, 2020 7:09 am
by Janusz
Steven,
To summarize above topic - there are some issue to make clone of objects added/created manually. When FastForm is used there is no issue.
I think that quick solution for that can be to add default value equal to 0 for the: sob_input_count & sob_all_order in zzzzsys_object. Because NULL value there is not allowing clone.

Code: Select all

ALTER TABLE `zzzzsys_object` CHANGE `sob_input_count` `sob_input_count` BIGINT(20) NULL DEFAULT '0';
ALTER TABLE `zzzzsys_object` CHANGE `sob_all_order` `sob_all_order` INT(11) NULL DEFAULT '0';
During my test I did not notice any drawback related to that.

Please find enclosed a movie showing the subject (not very short - but wanted to present whole process)
https://drive.google.com/file/d/1xDU3YZ ... sp=sharing
(not to watch the whole movie the key info is at duration 6:30 at the movie)

and some explanation to the movie:
q11_ - added just only to allow quick filterig
...FF... - objects created with FastForm
...M1.. - objects created manually on default setup
...M2.. - objects created manually after changing default value to 0 for sob_input_count & sob_all_order
as result we can see that:
clone is not working for ..M1.. objects
but for ..M2.. is OK

Would it be possible to implement this with next release? - of course if no other drawbacks related to that.

Janusz

Re: Error trying to clone an object

Posted: Sat Oct 31, 2020 11:54 pm
by admin
Janusz,

I have added your fix to Github.

Thanks.


Steven

Re: Error trying to clone an object

Posted: Sun Nov 01, 2020 5:59 pm
by Janusz
Steven,
Thanks a lot for implementing this. The Github copy works fine :-)
And one info - I noticed as well the new update on the Sourceforge - but still with previous version of nubuilder4.sql (with DEFAULT NULL for sob_all_order and sob_input_count).

Janusz

Re: Error trying to clone an object

Posted: Fri Nov 06, 2020 1:25 am
by admin
Janusz,

I think I've fixed it on Github now.

Please test it.


Steven