SELECT superclass
FROM objects
WHERE objtype='C' AND objName='Class1' AND superclass<>''
and Xcode issues this warning at RUNTIME
misuse at line 35812 of [1b37c146ee]
The error message returned by SQLite is SQLite Error [0] Ok.
In this particular instance I expect 0 records to be returned, and the program runs properly, it just issues this as a WARNING, not an ERROR
any ideas?
There are no threads, all SQLite statements are executed in series, and only after previous one are completed, there are many SQL queries in the app and this is the only one that issues this warning⌠all other operate silently as expected.
If I run this in my sqleditor it is fine, but then as noted above this is a WARNING, not an error
superclass is NOT defined as âNot Nullâ , but then ââ is not null
ââ != null
objtype is defined in the DDL as âobjTypeâ, but then SQLite is not case sensitive when it comes to field names, and if it were then a ERROR would be issued not only on this query, but on dozens of other also in this app
Everything is <> Null, even Null! The only expression that will return True when comparing to a Null value is âisâ (and âis notâ):
superclass is not null
But, of course, empty strings are also not null. Whenever I have a column that can contain Nulls and Iâm looking for those that have no value, I use Coalesce().
But in this case youâre not looking for empty values, but for non-empty values, so it doesnât matter. But what Iâm getting at is maybe Swift/Xcode recognizes that youâre comparing against possibly null values and is attempting (poorly) to warn about the pitfalls of doing so. Especially if running the same query from the sqlite3 shell gives no warning.
sqlite does NOT treat <> null the same as âis not nullâ
this is in macOS terminal using the sqlite3 command
sqlite> create table foo(id integer primary key, value text) ;
sqlite> insert into foo(id) values(1) ;
sqlite> insert into foo(id,value) values(2,'') ;
sqlite> insert into foo(id,value) values(3,'abc') ;
sqlite> select * from foo where value <> null ;
sqlite> select * from foo where value is not null ;
2|
3|abc
sqlite>
Only because it seems like there just isnt any reason that the warning should be coming up at all
If the columns arent null, and always have a value (even if it is an empty string) its hard to imagine why this warning shows up
Does this warning show up only when running ?
Can you stop at the offending line of code and investigate ?
Just seems really odd
âhard to imagineâ I agree, which is why I brought it up here
Show only when running? Not sure how it could appear at any other tiime???
Other than the fact I located the offending line by inserting âprint statementsâ before and after, and that the execution returns a 0 error value, not sure what else could be investigate
let SQL = "SELECT superclass FROM \(objectTABLE) WHERE objtype='C' AND objName='\(windowNAME)' AND superclass!=''"
print(SQL)
let rs = DB.SQLSelect(SQL)
<<<--- warning appears here
print(DB.ErrorMessage)
print("done\n")
SELECT superclass FROM objects WHERE objtype='C' AND objName='Class1' AND superclass!=''
misuse at line 35812 of [1b37c146ee]
SQLite Error [0] Ok.
done
Which is why I assumed this warning is occuring in the Swift/Xcode framework/library/driver/whatever. Itâs either an outright bug, or an incomplete âwarningâ system (so still a bug). The word âmisuseâ indicates a comparison against a âproper useâ, which is why I brought up the case of nulls.
Itâs simple to see if Iâm right. Make the column NOT NULL. Doesnât matter if it currently has no null values if the framework is only looking at the table definition.
Or try changing the query. Select * instead of just superclass, just to see what happens.
You could also post the actual table structure. Maybe someone will see something there.