SET NAMES utf8mb4;
DROP TABLE IF EXISTS `test_boolean`;
CREATE TABLE `test_boolean` (
`f_bit` bit(1) NOT NULL DEFAULT b'0',
`f_tiny` tinyint(1) NOT NULL DEFAULT 0
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
-- Test values
INSERT INTO `test_boolean` VALUES (b'0', 0);
INSERT INTO `test_boolean` VALUES (b'0', 1);
INSERT INTO `test_boolean` VALUES (b'1', 0);
INSERT INTO `test_boolean` VALUES (b'1', 1);
SELECT * FROM test_boolean;
Now run this app connecting to it:
Var db As new MySQLCommunityServer
db.Host = "db1.thedatabase.com"
db.Port = 3306
db.DatabaseName = "test_database"
db.UserName = "theUser"
db.Password = "thePassword"
Try
db.Connect
// Use the database
Catch error As DatabaseException
// DB Connection error
MessageBox(error.Message)
End Try
Var rs As RowSet = db.SelectSQL("select * from test_boolean")
Do until rs.AfterLastRow
System.DebugLog If(rs.Column("f_bit").BooleanValue, "True ", "False ")+If(rs.Column("f_tiny").BooleanValue, "True", "False")
rs.MoveToNextRow
Loop
break // Check messages
For Each row As DatabaseRow In rs
System.DebugLog If(row.Column("f_bit").BooleanValue, "True ", "False ")+If(row.Column("f_tiny").BooleanValue, "True", "False")
Next
You’ve just found another bug in the 'dozen times+'™ DatabaseRow object.
DatabaseRow Columns data and methods differed many times from RowSet Columns data and methods, Xojo extended the surface of errors and mistakes duplicating codes and introducing bugs in one place and fixing the other and vice-versa. They implemented the reverse of “single point of failure”, kind of spreading points of failure.
So until now we have found 3 related bugs. Open an Issue report:
// Those 3 method calls are returning False all the time, even for 1 values
// DB engine used on test: MySQL (make sure using another one does not repeat the bug)
RowSet.Column("bit_field").BooleanValue
DatabaseRow.Column("bit_field").BooleanValue
DatabaseRow.Column("tiny_int_field").BooleanValue