Boolean fields

Here you can put ideas for new functionalities and improvements.

Moderators: hugo, alexandre, rmvanarkel

Post Reply
rmvanarkel
Posts: 240
Joined: Tue Oct 05, 2010 1:14 pm

Boolean fields

Post by rmvanarkel » Wed Dec 20, 2017 12:31 pm

Dear forum users,

In Cyclos 4.9.1 we will do a minor migration for boolean profile fields. In this post you can find some additional information:

Before Cyclos 4.9 booleans fields with the value false where only saved when they were actively clicked on. This was not a major problem when searching for fields with the value true. However when searching for the value false not all results were shown. This problem is fixed in Cyclos 4.9. In Cyclos 4.9.1 we will also migrate all user boolean fields with no value to the default value of the field. If you wish to filter on a boolean field for transactions, advertisements or records you can run the following queries. Please always test this first in a test environment and only when you know what you are doing!


SQL query to create boolean custom field values for transactions.

Code: Select all

insert into transaction_custom_field_values 
	(boolean_value, field_id, owner_id, version)
select 
	false, trcf.id, t.id, 1
from 
	transactions t join 
	transfer_types tt on t.type_id = tt.id join 
	transfer_types_custom_fields ttcf on ttcf.transfer_type_id = tt.id join 
	transaction_custom_fields trcf on trcf.id = ttcf.custom_field_id
where 
	trcf.type='BOOLEAN' and 
	not exists (select 1 from transaction_custom_field_values trcfv where trcfv.owner_id = t.id and trcfv.field_id = trcf.id);

SQL query to create boolean custom field values for advertisements.

Code: Select all

insert into ad_custom_field_values 
	(boolean_value, field_id, owner_id, version)
select 
	acf.default_boolean_value, acf.id, a.id, 1
from 
	ads a join 
	users u on u.id=a.owner_id, 
	ad_custom_fields acf
where 
	acf.network_id = u.network_id and 
	acf.type='BOOLEAN' and 
	not exists (select 1 from ad_custom_field_values acfv where acfv.owner_id = a.id and acfv.field_id = acf.id);

SQL query to create boolean custom field values for records.

Code: Select all

insert into record_custom_field_values 
	(boolean_value, field_id, owner_id, version)
select 
	rcf.default_boolean_value, rcf.id, r.id, 1
from 
	records r join 
	record_types rt on r.type_id = rt.id join 
	record_custom_fields rcf on rcf.record_type_id = rt.id
where 
	rcf.type='BOOLEAN' and 
	not exists (select 1 from record_custom_field_values rcfv where rcfv.owner_id = r.id and rcfv.field_id = rcf.id);

Post Reply