umbraco / Umbraco-CMS Public
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
v10 SQLite support + distributed locking abstractions #11922
Conversation
2216813
to
1e52264
Compare
94f94ee
to
2748670
Compare
src/Umbraco.Infrastructure/Persistence/NPocoDatabaseTypeExtensions.cs
Outdated
Show resolved
Hide resolved
.From<UserLoginDto>() | ||
.Where<UserLoginDto>(x => x.SessionId == SqlTemplate.Arg<Guid>("sessionId")) | ||
.ForUpdate()); | ||
.ForUpdate() | ||
.SelectTop(1)); // Stick at end, SQL server syntax provider will insert at start of query after "select ", but sqlite will append limit to end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Npoco (and our extension) expression builders are pretty linear, the final query is written in order.
The SelectTop extension will add "TOP {n}" at the first select found in the current query.
But for RDBMS with Limit it's hard for us to know when/where to append to query as later statements may still be chained into the builder.
This kindof sucks but if you always put SelectTop last for a query (or sub query) it always works.
|
||
namespace Umbraco.Cms.Infrastructure.Persistence; | ||
|
||
public abstract class ScalarMapper<T> : IScalarMapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NPoco + MS.Data.Sqlite workaround sad times.
ExecuteScalar<T> in npoco only works for types supported by Convert.ChangeType (e.g. not byte[] or string -> Guid which we need) so we have to workaround for now.
Not a problem with System.Data.Sqlite whose upstream object ExecuteScalar
returns Guid by magic, MS team wanted less magic so we get string or byte[].
I don't think there is a way around this, however perhaps the setup should be more consistent with the rest of the provider bundle (e.g. as part of DbProviderFactoryCreator)
|
||
foreach (var record in records) | ||
{ | ||
database.Insert(record); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we convert to query text we can instantiate params a single time and rebind (future performance enhancement, not top priority)
{1B28FC3E-3D5B-4A46-8961-5483835548D7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1B28FC3E-3D5B-4A46-8961-5483835548D7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1B28FC3E-3D5B-4A46-8961-5483835548D7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{2A5027D9-F71D-4957-929E-F7A56AA1B95A}.SkipTests|Any CPU.ActiveCfg = Debug|Any CPU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stops codeql kicking off about passwords in test projects etc
connection.Open(); | ||
|
||
using SqliteCommand command = connection.CreateCommand(); | ||
command.CommandText = "PRAGMA journal_mode = wal;"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not settable on connection string for MS.Data.Sqlite
7cad38c
to
ff825fd
Compare
@@ -8,5 +8,5 @@ public static class Constants | |||
/// <summary> | |||
/// SQLite provider name. | |||
/// </summary> | |||
public const string ProviderName = "System.Data.SQLite"; | |||
public const string ProviderName = "Microsoft.Data.SQLite"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We switched to support (MacOS) osx-arm (native interop library for sys.data missing osx-arm binaries)
_globalSettings = globalSettings; | ||
_log = log; | ||
|
||
_scalarMappers = new Dictionary<Type, IScalarMapper> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this move to DbProviderFactoryCreator?
487bc3a
to
7d7eb57
Compare
9ea8b57
to
86e4cd2
Compare
eb51053
to
263c454
Compare
TODO: InMemoryDistributedLockingMechanism. Note: Nuked SqlServerDistributedLockingMechanismTests, will still sleep at night. Is covered by Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.LockTests
InMemoryDistributedMechanism was pretty rubbish and now we have a decent implementation for SQLite as we no longer block readers see 8d1f42b. Also drop the CollectionBuilder setup, instead do the same as we do for syntax providers etc, it's more automagical so we never require an explicit selection although we are allowing for it. However keeping the optional IUmbracoBuilder constructor param for CollectionBuilders as it's extremely useful.
Doesn't seem worth it to extract db name from connection string.
There's no point in running the query just to make a single test pass.
15e077f
to
a74c984
Compare
|
No description provided.