I have a table defined as:
try db.create(table: "availablePlayer") {table in
table.autoIncrementedPrimaryKey("playerId")
table.column("name"), .text).notNull()
In my testing, I am selecting 9 rows from one table and inserting those rows into this "availablePlayer" table. This works. When I query the "availablePlayer" table, I have playerId's from 301 to 309. I then attempt to add a new player to the "availablePlayer" table. The trace show this statement as
INSERT INTO availablePlayer (name) VALUES('Smith').
After the insert, I execute
let lastRow = db.lastInsertedRowID
which returns a value of 310. This all makes sense. But when I use DB Browser for SQLite to view the rows in the "availablePlayer" table, there is no row with a playerId of 310 and a name of "Smith". Also, when I query sqlite_sequence, it show the seq column as having a value of 310.
If I then delete all of the rows in the "availablePlayer" table and rerun my app, the 9 rows get inserted. And the rows have playerId's of 311 to 318
I am not getting any errors.
As a follow up. I commented out the code where I deleted the existing rows in "availablePlayer" and then populate it. So now when I added a new player, the table was empty. The new player was added successfully. I have move my delete into its own {db in ...} and instead of doing all of my inserts in a loop within a single {db in ...} structure, I have moved the loop outside of the {db in ... }. But none of this has had a positive affect on the outcome. I just am at a loss.