When trying to get the schema like this, it’ll return nil:
mDB.FieldSchema ("Order")
That’s because “ORDER” is also a reserved word, meaning that one needs to escape it when addressing it with SQL commands. Obviously, the Xojo code doesn’t follow this rule properly.
The work-around is to escape the name yourself, e.g. like this:
Eli, it’s a but because I am not writing raw SQL code here but am using a high-level function that expects a plain table name. In the same way that TableSchema does not escape the returned names, I should not have to escape them when passing the same names to related functions.
this “anomoly” [as I too don’t consider it a ‘bug’] exists in the database ENGINE, not in XOJO…
any other “front end” to the same database would react in the same or similar manner
Ah … sqlite does NOT like this table definition and barks
Last login: Wed Feb 24 07:54:29 on ttys000
server:~ npalardy$ sqlite3
SQLite version 3.7.13 2012-07-17 17:46:21
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE 'Order' (
...> 'rowid' INTEGER DEFAULT NULL PRIMARY KEY AUTOINCREMENT,
...> 'txt' TEXT
...> ) ;
sqlite> select * from order ;
Error: near "order": syntax error
sqlite>
it looks like different vendors “reserve” different words
google for “sql reserved words” and you’ll see there are a lot of vendor specific lists
It seems like the Xojo database api should be handling the escaping. In SQLite, it’s valid to use even spaces in your identifiers. Xojo should handle this correctly.
However, I’d be willing to bet this behavior will not be changed because it would silently break existing code. If you have written your code as FieldSchema("[Order]") and all of the sudden escaping happens for you, this would no longer return the correct result.