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

Strict mode tables not working, syntax error #28124

Closed
voltagex opened this issue May 30, 2022 · 11 comments
Closed

Strict mode tables not working, syntax error #28124

voltagex opened this issue May 30, 2022 · 11 comments

Comments

@voltagex
Copy link

tl;dr can you please update the underlying sqlite library to at least 3.37.0?

CREATE TABLE ... STRICT does not appear to be working in Microsoft.Data.Sqlite

See https://www.sqlite.org/stricttables.html. This feature requires SQLite 3.37.0 (2021-11-27)

Command line:

 sqlite3.exe -cmd "CREATE TABLE MyTable (MyID INTEGER) STRICT;"
SQLite version 3.37.1 2021-12-30 15:30:28
Enter ".help" for usage hints.
sqlite> .schema MyTable
CREATE TABLE MyTable (MyID INTEGER) STRICT;
sqlite> .quit

(via LinqPad, using statements not included )

void Main()
{
	var connection = new SqliteConnection("Data Source=:memory:");
	connection.Open();
	var command = connection.CreateCommand();
	command.CommandText = "CREATE TABLE MyTable (MyID INTEGER) STRICT";
	command.ExecuteNonQuery();
}

Include stack traces

SQLite Error 1: 'near "STRICT": syntax error'.
at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
   at UserQuery.Main(), line 7

Include version information

Microsoft.Data.Sqlite version:

I have tried

Microsoft.Data.Sqlite 6.0.5
SQLitePCLRaw.lib.e_sqlite3 2.0.6
SQLitePCLRaw.provider.e_sqlite3 2.0.6

and
Microsoft.Data.Sqlite 7.0.0-preview.4.22229.2
SQLitePCLRaw.bundle_e_sqlite3 2.0.8-pre20220111224339
SQLitePCLRaw.core 2.0.8-pre20220111224339

SELECT sqlite_version() from the included library shows 3.35.5 for both stable and prerelease

Target framework: (e.g. .NET 5.0): .NET 6 or .NET 7
Operating system: Windows 11

@voltagex
Copy link
Author

Side question: how is Microsoft.Data.Sqlite built? I don't see it in the GitHub actions - for the experiments and side projects I'm working on, I'd be happy to build my own with a newer sqlite.

@roji
Copy link
Member

roji commented May 30, 2022

@voltagex the CI build is done using Azure Pipelines, so see azure-pipelines.yml in the repo root if you're interested. However, for building locally see these instructions (the CI shouldn't really be relevant for you).

@bricelam can provide an answer for the the SQLLite version.

@voltagex
Copy link
Author

@roji Thanks! Looked straight past the azure-pipelines.yml. Oops!

Thanks for the pointer to the local build instructions, too.

@voltagex
Copy link
Author

voltagex commented May 30, 2022

It looks like the process to update e_sqlite3.dll is quite involved and seemingly requires a build of https://github.com/ericsink/SQLitePCL.raw. cc @ericsink

Edit: Maybe only the Microsoft.Data.Sqlite.Core dependency version needs an update to 2.1.0?

<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.0" /> in my csproj file and the STRICT modifier is working.

@ajcvickers
Copy link
Contributor

@voltagex As you say, the new version requires a new PLC.raw package. As such, this is an external issue--we will automatically update the EF provider once a new version is available.

@voltagex
Copy link
Author

@ajcvickers there's an updated version, https://www.nuget.org/packages/SQLitePCLRaw.core/ is at 2.1.0

@ajcvickers
Copy link
Contributor

@voltagex And that update has now been picked up: 5fc5762

@bricelam
Copy link
Contributor

bricelam commented Jun 1, 2022

Note, you can also use the 2.1.0 version of SQLitePCLRaw with older versions of Microsoft.Data.Sqlite.

<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.5" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.0" />

@ErikEJ
Copy link
Contributor

ErikEJ commented Jun 1, 2022

But does 2.1 include the updated SQLite engine and how would one know?

@ericsink
Copy link

ericsink commented Jun 1, 2022

@ErikEJ I think maybe one answer to that is "look at the SQLitePCLRaw release notes".

Which I forgot to do for 2.1. :-(

My bad. I'll fix that.

@ericsink
Copy link

ericsink commented Jun 1, 2022

@ErikEJ Done: https://github.com/ericsink/SQLitePCL.raw/releases/tag/v2.1.0

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants