Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contrib Error inserting into a table having an Identity and a Computed columns #1454

Open
AteCoder opened this issue May 5, 2020 · 4 comments
Open

Comments

@AteCoder
Copy link

@AteCoder AteCoder commented May 5, 2020

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;

@NickCraver
Copy link
Member

@NickCraver NickCraver commented May 6, 2020

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!

@AteCoder
Copy link
Author

@AteCoder AteCoder commented May 6, 2020

@NickCraver
Copy link
Member

@NickCraver NickCraver commented May 7, 2020

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?

@AteCoder
Copy link
Author

@AteCoder AteCoder commented May 7, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.