Running a two-part query results in the first query running twice.
Code Snippet (if applicable) to Reproduce Problem:
var/database/query/q = new("INSERT INTO players (name,ckey) VALUES (?,?);SELECT last_insert_rowid()",lowertext(name),ckey)
if(q.Execute(playerdb)&&q.NextRow())
...yada yada
Workaround:
Separate into two blocking queries... Which is really entirely counterintuitive.
var/database/query/q = new("INSERT INTO players (name,ckey) VALUES (?,?)",lowertext(name),ckey)
if(q.Execute(playerdb))
q.Clear()
q.Add("SELECT last_insert_rowid()")
if(q.Execute(playerdb)&&q.NextRow())
var/list/l = q.GetRowData()
return l["last_insert_rowid()"]
world.log << q.ErrorMsg()
Expected Results:
Insert once, then return a single row to get the last_instert_rowid() value from SQLlite.
Actual Results:
Performs the first query twice, inserting two identical rows and returns no rows.
Also, databasequery is SEVERELY lacking in standardized behavior for last_row information. You have to perform a second query to get the row of the value you just changed/inserted, which is very much something that no other database implementation I've ever worked with requires.
Most Execute() functions return the row that was affected by the query on an Insert.
There's no way this is an actual bug, because someone else would have reported it by now, right? Right?
I'm not sure it would necessarily be best to return a value other than pass/fail for Execute() (I understand the reasoning, but it would frell up any existing implementations), but /database could be extended to get that info fairly painlessly.
I'm not averse to adding some convenience routines like that to stddef.dm.