Allow casting of integers 0/1 to new boolean data type false/true
-----------------------------------------------------------------

                 Key: CORE-3849
                 URL: http://tracker.firebirdsql.org/browse/CORE-3849
             Project: Firebird Core
          Issue Type: Improvement
          Components: Engine
    Affects Versions: 3.0 Initial
            Reporter: lacak
            Priority: Minor


AFAIK current implementation allows casting of character strings 'false' / 
'true' to boolean values false / true.
(it is compliant with sql standard)

It will be nice if there will be supported also casting from 0 / 1 to false / 
true like it is supported in other RDBMSs
(it will increase cross database portability and compatibility with others 
RDBMSs where exists native BOOLEAN data type or  where is "emulated" using 
other data types like MSSQL: BIT (0/1) or MySQL:BOOL (synonym for TINYINT))

Here are some examples why 0/1 :

PostgreSQL: http://www.postgresql.org/docs/9.0/interactive/datatype-boolean.html

Ingres: "Boolean columns accept as input the literal values FALSE and TRUE, 0 
and 1 (which correspond to false and true, respectively), and the strings 
'FALSE' and 'TRUE'." ... "CAST(integer AS BOOLEAN) is accepted for values 0 and 
1."

MySQL: "However, the values TRUE and FALSE are merely aliases for 1 and 0" 
http://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html

>From sql standard:
---------------------------
"In comparisons of boolean values, True is greater than False"

(from subclause 13.4 Calls to an <externally-invoked procedure>)
"If the caller language of EP is C, then a reference to PN that assigns the 
value False to PN implicitly assigns the value 0 (zero) to PI; a reference to 
PN that assigns the value True implicitly assigns the value 1 (one) to PI."

>From programing languages world:
-------------------------------------------------
in C99 standard (ISO/IEC 9899) is _Bool :
"An object declared as type _Bool is large enough to store the values 0 and 1."
"true which expands to the integer constant 1, false which expands to the 
integer constant 0"

in C++ (ISO/IEC 14882) is Bool:
"An rvalue of type bool can be converted to an rvalue of type int, with false 
becoming zero and true becoming one."
"If the source type is bool, the value false is converted to zero and the value 
true is converted to one."

in Pascal (ISO/IEC 10206:1990):
"The ordinal numbers of the truth values denoted by false and true shall be the
integer values 0 and 1 respectively."


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to