Contrib Error inserting into a table having an Identity and a Computed columns
Opened this issue · 4 comments
The insert error is:
System.Data.SQLite.SQLiteException: SQL logic error
near ")": syntax error
Apparently, the culprit is the following command
var cmd = $"INSERT INTO {tableName} ({columnList}) VALUES ({parameterList}); SELECT last_insert_rowid() id";
which is part of the Insert function of the Contrib SQL Mapper Extensions for the SQLite implementation. Because both fields are auto-generated, the column and parameter lists are empty and the command fails.
The following command does work:
INSERT INTO [<table name>] Default Values;
To clarify: in this case we're talking about effectively inserting nothing and getting back a PK of the fully automatic row? I...yeah, I bet that does bad things. I'd honestly just say this isn't a use case that was ever considered.
More so: I'm not sure what the insert statement would look like. What would the raw version of this be, that does what you expect here? I'm having trouble picturing the use case and an example would help!
Thanks David, I get the intent here but I'm honestly not sure what the SQL statement looks like to do with a thing. I'm not sure there is valid SQL to do this. Do you have an example of the INSERT
statement that would do this - totally ignoring Dapper exists, what would it look like?