Trouble with tinyint booleans
Posted: Tue 08 May 2012 16:59
I have a query that uses a union of two separate queries. Several of the columns are tinyint boolean fields in the table. The trouble is that when I use the TMyQuery field editor, it casts all the tinyint boolean fields as TinyInt - even if I check the EnableBoolean property.
Obviously, my app won't correctly set checkboxes that use these fields when they are cast as Tinyints.
If I delete the automatically assigned tinyint fields using the field editor and replace them with boolean data fields, my application dies with a "quAccountsReceivable: Type mismatch for field 'deposited', expecting: Boolean actual: SmallInt."
Does anyone have any ideas on how to work around this problem?
Here is the table that contains the boolean flags:
Here is the query:
Obviously, my app won't correctly set checkboxes that use these fields when they are cast as Tinyints.
If I delete the automatically assigned tinyint fields using the field editor and replace them with boolean data fields, my application dies with a "quAccountsReceivable: Type mismatch for field 'deposited', expecting: Boolean actual: SmallInt."
Does anyone have any ideas on how to work around this problem?
Here is the table that contains the boolean flags:
Code: Select all
CREATE TABLE `zzzz`.`incomeitems` (
`id` int(10) unsigned NOT NULL auto_increment COMMENT 'unique id',
`oid` int(10) unsigned default NULL,
`amount` double(9,2) NOT NULL ,
`checknum` varchar(20) default NULL,
`checkdate` datetime NOT NULL default '0000-00-00 00:00:00' COMMENT 'today',
`note` blob COMMENT 'misc note',
`did` int(10) unsigned default NULL COMMENT 'deposit id',
`paymenttype` int(10) unsigned NOT NULL COMMENT '1=cash,2=check,3=MO,4=other (use note)',
`aid` int(10) unsigned NOT NULL COMMENT 'paid-to agency',
`rid` int(10) unsigned default NULL COMMENT 'pay against this registration',
`deposited` tinyint(1) default '0' COMMENT 'Has this item been deposited?',
`nsf` tinyint(1) default '0' COMMENT 'Non sufficient funds?',
`voided` tinyint(1) NOT NULL default '0' COMMENT 'Has this item been voided?',
`hide` tinyint(1) NOT NULL default '0' COMMENT 'hide reversing items and the voided item',
`payingagency` int(10) unsigned default NULL COMMENT 'if agency payment, then put AID here',
`parent` int(10) unsigned default NULL COMMENT 'if this is a child record, then this field points to the parent incomeitems.id of parent',
`paymentsource` int(10) unsigned NOT NULL default '1' COMMENT '1=normal 2=split 3=collections',
PRIMARY KEY USING BTREE (`id`),
KEY `Index_2` USING BTREE (`oid`,`aid`),
KEY `Index_3` (`checkdate`),
KEY `Index_4` USING BTREE (`rid`)
) ENGINE=InnoDB AUTO_INCREMENT=967295 DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED COMMENT='InnoDB free: 1146880 kB';Code: Select all
select concat(concat_ws(", ", o.lastname, o.firstname), coalesce(concat(" ", o.middlename),"")) as payor,
i.*,
d.depositdate,
d.voided as depvoid
from incomeitems i
left join deposits d on (i.did=d.id)
left join offenders o on (i.oid=o.id)
where i.oid is not null and parent is null
union
select o.agencyname as payor,
i.*,
d.depositdate,
d.voided as depvoid
from incomeitems i
left join deposits d on (i.did=d.id)
left join contacts.agencies o on (i.payingagency=o.id)
where i.oid is null and parent is null