Loading a SQLite file some booleans load always as false.
The row loaded looks like:
Var rs As RowSet
Try
rs = db.SelectSQL(sql)
If rs <> Nil Then
Var c as CombatClass
mCombats.RemoveAll
for each row as DatabaseRow in rs
c = New CombatClass(false)
var test as Boolean = row.Column("applied").BooleanValue
var test2 as integer = row.Column("applied").IntegerValue
c.applied = row.Column("applied").BooleanValue
test is always false, test2 is 1
Is anyone experimente something similar?
“Boolean Datatype. SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true)” https://www.sqlite.org/datatype3.html
originally i know true as -1 and false as 0 (MS VB 6)
Var db As New SQLiteDatabase
call db.Connect
call db.ExecuteSQL("CREATE TABLE t1 (applied Int); INSERT INTO t1 (applied) VALUES (1);")
Var rs As RowSet
rs = db.SelectSQL("SELECT * FROM t1")
var asBoolean as Boolean = rs.Column("applied").BooleanValue // RowSet Returns True correctly
var asInteger as Integer = rs.Column("applied").IntegerValue
break
If rs <> Nil Then
For each row as DatabaseRow in rs
asBoolean = row.Column("applied").BooleanValue // Another DatabaseRow error, False???
asInteger = row.Column("applied").IntegerValue
break
Next
End
I save the values I need. The usual default for SQL is 0 = False, 1 = True. Take for example MSSQL Server, internally its boolean type is a bit field of 1 bit. So it can be Just those 2 values.
But, when evaluating expressions casting numbers to booleans, whatever non zero is True, Zero = False.
In SQLite we have just Integer fields to store it, so the rule 0 = False is what is used.
Since the conception, DatabaseRow seems a never tested feature. Never seem one feature so plagued by bugs as it is. I guess a dozen where found, and I thought it finally was stable, but I see it isn’t.
DatabaseRow .Column( ).BooleanValue // does not work
Accessing the value directly from the RowSet works.
It is strange that you say that your code worked until now.
If you visit the reported bug in Issues, they say that the problem is present in, at least, Xojo 2022r2, 2022r3.2, 2022r4.1
The bug is with the use of databaserow (from what I can tell):
for each row as DatabaseRow in rs
so, if you change the for each row logic to use the rs directly (do…loop maybe?) then it should work.