Forum OpenACS Development: Categories pkg - Add new tree

Request notifications

Collapse
Posted by Iuri Sampaio on
Hi there,

I found a bug on categories, adding a new category tree. The error happens in the latest oacs core. See bellow my contribution! :) Happy new year!

The solution or fixes that I foresaw were whether amend the datatype substantially or write a quik casting fix to the .xql file. You may guess which one I applied!



select category_tree__new (
:tree_id,
:locale,
:name,
:description,
CAST(:site_wide_p AS boolean),
current_timestamp,
:user_id,
:creation_ip,
:context_id
)

Best wishes,
Iuri

Error in include template "/packages/categories/lib/tree-form": Transaction aborted: Database operation "0or1row" failed (exception ERROR, "ERROR: column "site_wide_p" is of type boolean but expression is of type character LINE 4: (v_tree_id, p_site_wide_p) ^ HINT: You will need to rewrite or cast the expression. QUERY: insert into category_trees (tree_id, site_wide_p) values (v_tree_id, p_site_wide_p) CONTEXT: PL/pgSQL function "category_tree__new" line 26 at SQL statement ") ERROR: column "site_wide_p" is of type boolean but expression is of type character LINE 4: (v_tree_id, p_site_wide_p) ^ HINT: You will need to rewrite or cast the expression. QUERY: insert into category_trees (tree_id, site_wide_p) values (v_tree_id, p_site_wide_p) CONTEXT: PL/pgSQL function "category_tree__new" line 26 at SQL statement SQL: select category_tree__new ( '425826', 'en_US', 'Geneve', 'Geneve Map. Regions and cartiers listed hierarquically ', 'f', current_timestamp, '667', '192.199.241.135', '6543' )

Collapse
Posted by Iuri Sampaio on
Hi there,

I got 2 more. One adding a category and the other mapping a tree. The work is very simple.

Best wishes,
Iuri

Database operation "0or1row" failed (exception ERROR, "ERROR: column "assign_single_p" is of type boolean but expression is of type character
LINE 5: p_assign_single_p, p_require_category_p, p_widge...
^
HINT: You will need to rewrite or cast the expression.
QUERY: insert into category_tree_map
(tree_id, subtree_category_id, object_id,
assign_single_p, require_category_p, widget)
values (p_tree_id, p_subtree_category_id, p_object_id,
p_assign_single_p, p_require_category_p, p_widget)
CONTEXT: PL/pgSQL function "category_tree__map" line 19 at SQL statement
")

ERROR: column "assign_single_p" is of type boolean but expression is of type character
LINE 5: p_assign_single_p, p_require_category_p, p_widge...
^

Collapse
Posted by Gustaf Neumann on
Iuri,

i tried to recreate to problem on a fresh and old, but upgraded site, but it worked in both cases without problems.

Which versions of the database and categories do you use exactly? My suspicion is that you do not have executed the following update scripts:

https://github.com/openacs/categories/blob/oacs-5-9/sql/postgresql/upgrade/upgrade-1.1.3d6-1.1.3d7.sql

Please submit a proper bug-report to the bugtracker
http://www.openacs.org/bugtracker/openacs/

Collapse
Posted by Iuri Sampaio on
Hi Gustaf,

psql (9.1.23) and categories 1.1.3d5

I saw the script changes the datatype directly to char. Good. I thought about solution. But, as at the time I solved it, casting the variable, I haven't had the certainty neither visibility of the impact that such a datatype chang would have along the source code

Then I decided to CAST the variable on every broken piece of code that appear while I was browsing the package and creating the stuff.

Bug is created. #3298
http://www.openacs.org/bugtracker/openacs/bug?bug_number=

Best wishes

Collapse
Posted by Gustaf Neumann on
The problem existed in the categories package version 1.1.3d5 or 1.1.3d6 and was fixed by antonio on Nov 15, 2016. The current version of the categories package in the oacs-5-9 branch (1.1.3d7) works properly and does not need the cast operator.