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

SQLite: RETURNING clause doesn't work with virtual tables #29512

Closed
roji opened this issue Nov 9, 2022 · 4 comments
Closed

SQLite: RETURNING clause doesn't work with virtual tables #29512

roji opened this issue Nov 9, 2022 · 4 comments

Comments

@roji
Copy link
Member

roji commented Nov 9, 2022

Our new usage of the RETURNING clause in 7.0.0 is incompatible with SQLite virtual tables. Note that the provider doesn't yet support creating virtual tables in migrations (but can still be used to update tables created externally/via raw SQL).

We can add metadata about virtual tables, which would trigger opting out of RETURNING. We can also add a general context option to opt out of it, which would be an escape hatch for any further incompatibility scenarios.

Note that we already automatically opt out of RETURNING for old versions of SQLite (#28911).

Thanks @JesperTreetop for reporting this in #27663 (comment).

@ajcvickers
Copy link
Contributor

/cc @bricelam to look into virtual tables.

roji added a commit to roji/efcore that referenced this issue Nov 25, 2022
Leaving a hook for checking for a table-based opt out of RETURNING

Fixes dotnet#29512
@bricelam
Copy link
Contributor

bricelam commented Dec 9, 2022

Virtual tables just have two pieces of information--the backing virtual table module, and a comma-separated list of zero or more arguments. The API could look something like this:

t.IsVirtualTable("csv", "filename='thefile.csv'");
t.IsVirtualTable("fts5", "Name", "Address", "Uuid ININDEXED", "tokenizer='porter ascii'");

@roji
Copy link
Member Author

roji commented Dec 22, 2022

Providing a standalone opt-out from RETURNING is now tracked by #29916 - should we have a separate issue to track implementing virtual tables in Sqlite?

@roji roji removed this from the 8.0.0 milestone Dec 22, 2022
@roji
Copy link
Member Author

roji commented Jan 3, 2023

Note: for anyone blocked by this, you can revert to the previous SQLite behavior (without the RETURNING clause) by calling ReplaceService as follows:

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    => optionsBuilder
        .UseSqlite("Filename=/tmp/foo.sqlite")
        .ReplaceService<IUpdateSqlGenerator, SqliteLegacyUpdateSqlGenerator>();

Note that SqliteLegacyUpdateSqlGenerator is considered an internal service (in the Internal namespace), and will very likely go away in EF 8.0. But this is a good workaround in the meantime.

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

Successfully merging a pull request may close this issue.

3 participants