Hi Doug,
AFAIK, this issue is not resolved. Yep, its still annoying :)
Chris
________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Doug Arthur
Sent: 01 June 2007 19:55
To: [email protected]
Subject: Re: [Reactor for CF] boolean vlaues in mysql
Was there every any support for this added to Reactor since this
discussion? I'm running into the problem now, and do not want to do any
hacky business. It's an annoying situation.
- Doug
On 11/15/06, Chris Blackwell <[EMAIL PROTECTED]>
wrote:
That works fine, but it's just a hack. I was hoping we
may be able to find a way to represent a boolean explicitly without
repurposing a different type. Its a shame that columns created as
BOOLEAN are reported as TINYINT(1) by MySQL .
fwiw, if your going to hack the ObjectDAO for mysql you
could change the readfields query by replacing
DATA_TYPE as dbDataType,
with
CASE
WHEN LEFT(COLUMN_COMMENT, 5) = "TYPE=" THEN
REPLACE(COLUMN_COMMENT, "TYPE=", "")
ELSE DATA_TYPE
END AS dbDataType,
You can then override column type using the comment
attribute (TYPE=boolean) for each column, tinyints are treated correctly
and hopefully it shouldn't clash with any real comments.
Ideally i'd like to see this kind of type overriding
added to the reactor xml, <field name="foo" alias="bar" datatype="
boolean" /> ?
Chris
________________________________
From: [EMAIL PROTECTED] [mailto:
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ] On
Behalf Of Angus Johnson
Sent: 15 November 2006 12:06
To: [EMAIL PROTECTED]
Subject: Re: [Reactor for CF] boolean vlaues in
mysql
Chris,
I don't have access to the work servers this
evening but from memory I modded the reactor framework objectDAO(??).
Upshot was that the mods converted any tinyint column types to boolean.
Downside is that we have to enforce a practice of only using TINYINT for
boolean in Mysql tables.
I can post the modded code tomorrow if
interested.
Angus
On 11/11/06, Chris Blackwell <
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:
I'm not sure that has any advantages,
MySQL stores pointers to the values you have assigned in the ENUM, in
the example you've given
index 0 => 1
index 1 => 0
Also, by default that would throw a
Test.Active.invalidLength error if you did setActive(true)
________________________________
From: [EMAIL PROTECTED]
[mailto: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
] On Behalf Of Sal Valverde
Sent: 10 November 2006 18:34
To: [EMAIL PROTECTED]
Subject: Re: [Reactor for CF] boolean
vlaues in mysql
I've been using ENUM('1','0')
thanks
sal
Chris Blackwell wrote:
Heres some sample code that demonstrates
the problem i have..
CREATE TABLE `Test` (
`TestId` int(10) unsigned NOT NULL
auto_increment,
`Active` tinyint(1) NOT NULL,
PRIMARY KEY (`TestId`)
)
<cfset test =
reactor.createRecord("Test")>
<cfset test.setActive(true)>
<cfset test.validate()>
<cfdump
var="#test._getErrorCollection().getErrors()#">
Results in a Test.Active.invalidType.
This result is totally expected, as
Reactor has to validate a TINYINT as numeric by default. Obviously it's
no problem to use 1/0 when hard coding the values, but i ran into the
proble m when processing a checkbox for an object like this.
<cfset
user.setActive(structkeyexists(form, "active"))>
You can pass in "true" or "false" to the
record and save it because in MySQL True/False are just synonyms for 1/0
and get converted internally (Try SELECT true + 0). You just can't
validate it "out of the box" with the default validator.
For now overriding the setter will do
the job
<cffunction name="setActive"
access="public" output="false" returntype="void">
<cfargument name="Active"
type="boolean" required="yes">
<cfset
super.setActive(iif(arguments.Active, 1, 0))>
</cffunction>
________________________________
From: [EMAIL PROTECTED] [
mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ]
On Behalf Of Dave Shuck
Sent: 10 November 2006 17:28
To: [EMAIL PROTECTED]
Subject: Re: [Reactor for CF] boolean
vlaues in mysql
We just set the column type to BOOLEAN
in MySQL 5 (although it later magically becomes TINYINT(1)), and pass
ColdFusion boolean values with no issues whatsoever.
~Dave
On 11/10/06, Chris Blackwell <
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:
How are people representing boolean
values in mysql (4 or 5) with
reactor? I've always used TINYINT(1)
but with reactor its causing a
problem because, by default, it
validates the field as numeric so I get
an invalidType error.
I've tried the BIT(1) datatype for
MySQL5, but CF can't convert the
value to a boolean, I'm actually not
sure what this returns now, it used
to be a synonym for TINYINT(1).
BOOL/BOOLEAN are converted to TINYINT(1)
by MySQL so those type are
useless, the mysql ObjectDAO will never
see this type.
For now I'm overriding the
setColumn(bool) to convert the boolean to 1/0
and call super.setColumn(int).
I've only just run into this issue as
I've started using Reactors
validation instead of my own.
Chris Blackwell
Web Developer
Telephone: +44 (0)117 373 1465
Email: [EMAIL PROTECTED]
This email is intended for the use of
the named recipient(s) only. Any
information contained within this
message or any of its attachments may
be confidential and privileged
information. Any unauthorized
disclosure, reproduction, distribution
or other dissemination or use of
this communication is strictly
prohibited.
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- --
--
~Dave Shuck
[EMAIL PROTECTED]
www.daveshuck.com
<http://www.daveshuck.com/>
Where's your Spot?
www.instantspot.com
<http://www.instantspot.com/>
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at:
http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- -- -- -- -- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[EMAIL PROTECTED]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --