On Fri, May 1, 2015 at 1:02 PM, Richard Newman <[email protected]> wrote:
> Here's a chunk of code.
>
> let history = "CREATE TABLE IF NOT EXISTS \(TableHistory) (" +
>> "id INTEGER PRIMARY KEY AUTOINCREMENT, " +
>> "guid TEXT NOT NULL UNIQUE, " +
>> "url TEXT NOT NULL UNIQUE, " +
>> "title TEXT NOT NULL "
>> ")"
>
>
> If you write it like this, even temporarily:
>
>
>> let history = ("CREATE TABLE IF NOT EXISTS \(TableHistory) (" +
>> "id INTEGER PRIMARY KEY AUTOINCREMENT, " +
>> "guid TEXT NOT NULL UNIQUE, " +
>> "url TEXT NOT NULL UNIQUE, " +
>> "title TEXT NOT NULL "
>> ")")
>
>
> then the compiler will find the bug (a missing '+') for you.
>
> Unaccompanied strings on their own are not compile errors!
>
In my opinion it is better to do this using a list and a join:
"CREATE TABLE IF NOT EXISTS \(TableHistory) (" +
join(",",
[ "id INTEGER PRIMARY KEY AUTOINCREMENT",
"guid TEXT NOT NULL UNIQUE",
"url TEXT NOT NULL UNIQUE",
"title TEXT NOT NULL",
]) + ")"
See Storage/SQL/RemoteTabs.swift.
Nick
_______________________________________________
mobile-firefox-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/mobile-firefox-dev