Skip to content

Commit

Permalink
upgrade 1.1.0-preview1 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
caleblloyd committed Oct 29, 2016
1 parent 3b60071 commit 0b5d1a6
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 88 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ protected override void ForeignKeyConstraint(
}
}

string ColumnList(string[] columns) => string.Join(", ", columns.Select(SqlGenerationHelper.DelimitIdentifier));
protected override string ColumnList(string[] columns) => string.Join(", ", columns.Select(SqlGenerationHelper.DelimitIdentifier));
}

public static class StringExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ public class MySqlQueryContext : RelationalQueryContext
public MySqlQueryContext(
[NotNull] Func<IQueryBuffer> queryBufferFactory,
[NotNull] IRelationalConnection connection,
[NotNull] IStateManager stateManager,
[NotNull] IConcurrencyDetector concurrencyDetector)
: base(queryBufferFactory, connection, stateManager, concurrencyDetector)
[NotNull] LazyRef<IStateManager> stateManager,
[NotNull] IConcurrencyDetector concurrencyDetector,
[NotNull] IExecutionStrategyFactory executionStrategyFactory)
: base(queryBufferFactory, connection, stateManager, concurrencyDetector, executionStrategyFactory)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,17 @@ public class MySqlQueryContextFactory : RelationalQueryContextFactory
private readonly IRelationalConnection _connection;

public MySqlQueryContextFactory(
[NotNull] IStateManager stateManager,
[NotNull] ICurrentDbContext currentContext,
[NotNull] IConcurrencyDetector concurrencyDetector,
[NotNull] IRelationalConnection connection,
[NotNull] IChangeDetector changeDetector)
: base(stateManager, concurrencyDetector, connection, changeDetector)
[NotNull] IExecutionStrategyFactory executionStrategyFactory)
: base(currentContext, concurrencyDetector, connection, executionStrategyFactory)
{
_connection = connection;
}

public override QueryContext Create()
=> new MySqlQueryContext(CreateQueryBuffer, _connection, StateManager, ConcurrencyDetector);
=> new MySqlQueryContext(CreateQueryBuffer, _connection, StateManager, ConcurrencyDetector, ExecutionStrategyFactory);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,32 @@ public class MySqlDatabaseCreator : RelationalDatabaseCreator
{
private readonly MySqlRelationalConnection _connection;
private readonly IMigrationsSqlGenerator _migrationsSqlGenerator;
private readonly IRawSqlCommandBuilder _rawSqlCommandBuilder;
private readonly IRawSqlCommandBuilder _rawSqlCommandBuilder;

/// <summary>

/// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
/// </summary>
public MySqlDatabaseCreator(
[NotNull] MySqlRelationalConnection connection,
[NotNull] IMigrationsModelDiffer modelDiffer,
[NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
[NotNull] IMigrationCommandExecutor migrationCommandExecutor,
[NotNull] IModel model,
[NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder)
: base(model, connection, modelDiffer, migrationsSqlGenerator, migrationCommandExecutor)
public MySqlDatabaseCreator(
[NotNull] MySqlRelationalConnection connection,
[NotNull] IMigrationsModelDiffer modelDiffer,
[NotNull] IMigrationsSqlGenerator migrationsSqlGenerator,
[NotNull] IMigrationCommandExecutor migrationCommandExecutor,
[NotNull] IModel model,
[NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
[NotNull] IExecutionStrategyFactory executionStrategyFactory)
: base(model, connection, modelDiffer, migrationsSqlGenerator, migrationCommandExecutor, executionStrategyFactory)
{
Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder));
Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder));

_connection = connection;
_migrationsSqlGenerator = migrationsSqlGenerator;
_rawSqlCommandBuilder = rawSqlCommandBuilder;

_connection = connection;
_migrationsSqlGenerator = migrationsSqlGenerator;
_rawSqlCommandBuilder = rawSqlCommandBuilder;
}

/// <summary>
/// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,38 @@ public MySqlRelationalCommand(
}

protected override object Execute(
[NotNull] IRelationalConnection connection,
[NotNull] string executeMethod,
[CanBeNull] IReadOnlyDictionary<string, object> parameterValues,
bool openConnection,
bool closeConnection)
IRelationalConnection connection,
string executeMethod,
IReadOnlyDictionary<string, object> parameterValues,
bool closeConnection = true)
{
return ExecuteAsync(IOBehavior.Synchronous, connection, executeMethod, parameterValues, openConnection, closeConnection)
return ExecuteAsync(IOBehavior.Synchronous, connection, executeMethod, parameterValues, closeConnection)
.GetAwaiter()
.GetResult();
}

protected override async Task<object> ExecuteAsync(
[NotNull] IRelationalConnection connection,
[NotNull] string executeMethod,
[CanBeNull] IReadOnlyDictionary<string, object> parameterValues,
bool openConnection,
bool closeConnection,
IRelationalConnection connection,
string executeMethod,
IReadOnlyDictionary<string, object> parameterValues,
bool closeConnection = true,
CancellationToken cancellationToken = default(CancellationToken))
{
return await ExecuteAsync(IOBehavior.Asynchronous, connection, executeMethod, parameterValues, openConnection, closeConnection, cancellationToken).ConfigureAwait(false);
return await ExecuteAsync(IOBehavior.Asynchronous, connection, executeMethod, parameterValues, closeConnection, cancellationToken).ConfigureAwait(false);
}

private async Task<object> ExecuteAsync(
IOBehavior ioBehavior,
[NotNull] IRelationalConnection connection,
[NotNull] string executeMethod,
[CanBeNull] IReadOnlyDictionary<string, object> parameterValues,
bool openConnection,
bool closeConnection,
CancellationToken cancellationToken = default(CancellationToken))
{
Check.NotNull(connection, nameof(connection));
Check.NotEmpty(executeMethod, nameof(executeMethod));
var dbCommand = CreateCommand(connection, parameterValues);
object result;
if (openConnection)
{
if (ioBehavior == IOBehavior.Asynchronous)
await connection.OpenAsync(cancellationToken).ConfigureAwait(false);
else
connection.Open();
}

cancellationToken.ThrowIfCancellationRequested();
var mySqlConnection = connection as MySqlRelationalConnection;
Expand Down Expand Up @@ -121,8 +111,7 @@ private async Task<object> ExecuteAsync(
else
dataReader = dbCommand.ExecuteReader() as MySqlDataReader;

result = new RelationalDataReader(openConnection ? connection : null, dbCommand,
new SynchronizedMySqlDataReader(dataReader, mySqlConnection));
result = new RelationalDataReader(connection, dbCommand, new SynchronizedMySqlDataReader(dataReader, mySqlConnection));
}
catch (Exception)
{
Expand All @@ -137,27 +126,20 @@ private async Task<object> ExecuteAsync(
}
}
}
catch (Exception)
{
if (openConnection && !closeConnection)
{
connection.Close();
}
throw;
}
finally
{
if (closeConnection)
{
connection.Close();
}
if (locked && executeMethod != nameof(ExecuteReader))
{
// if calling any other method, the command has finished executing and the lock can be released immediately
// ReSharper disable once PossibleNullReferenceException
mySqlConnection.Lock.Release();
mySqlConnection.PoolingClose();
}
// ReSharper disable once PossibleNullReferenceException
if (!mySqlConnection.Pooling && closeConnection)
{
connection.Close();
}
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,25 +242,27 @@ protected void DoClose()
// Optomizations have been added to return connections to the pool faster
// Prefer PoolingOpen/Close functions when Connection Pooling is enabled

public bool Pooling => ConnectionStringBuilder.Pooling;

public void PoolingOpen()
{
if (ConnectionStringBuilder.Pooling)
if (Pooling)
{
DoOpen();
}
}

public async Task PoolingOpenAsync(CancellationToken cancellationToken = default(CancellationToken))
{
if (ConnectionStringBuilder.Pooling)
if (Pooling)
{
await DoOpenAsync(cancellationToken).ConfigureAwait(false);
}
}

public void PoolingClose()
{
if (ConnectionStringBuilder.Pooling)
if (Pooling)
{
DoClose();
}
Expand All @@ -271,7 +273,7 @@ public void PoolingClose()

public void Open()
{
if (!ConnectionStringBuilder.Pooling)
if (!Pooling)
{
DoOpen();
}
Expand All @@ -296,7 +298,7 @@ public void Open()

public async Task OpenAsync(CancellationToken cancellationToken = default(CancellationToken))
{
if (!ConnectionStringBuilder.Pooling)
if (!Pooling)
{
await DoOpenAsync(cancellationToken).ConfigureAwait(false);
}
Expand All @@ -321,7 +323,7 @@ public void Open()

public void Close()
{
if (!ConnectionStringBuilder.Pooling)
if (!Pooling)
{
DoClose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public override void Execute(IRelationalConnection connection)
var storeCommand = CreateStoreCommand();
try
{
using (var relationalDataReader = storeCommand.RelationalCommand.ExecuteReader(connection, storeCommand.ParameterValues, false))
using (var relationalDataReader = storeCommand.RelationalCommand.ExecuteReader(connection, storeCommand.ParameterValues))
{
Consume(relationalDataReader.DbDataReader);
}
Expand All @@ -192,7 +192,7 @@ public override void Execute(IRelationalConnection connection)
var storeCommand = CreateStoreCommand();
try
{
var dataReader = await storeCommand.RelationalCommand.ExecuteReaderAsync(connection, storeCommand.ParameterValues, false, cancellationToken).ConfigureAwait(false);
var dataReader = await storeCommand.RelationalCommand.ExecuteReaderAsync(connection, storeCommand.ParameterValues, cancellationToken).ConfigureAwait(false);
try
{
await ConsumeAsync(dataReader.DbDataReader, cancellationToken).ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion src/Pomelo.EntityFrameworkCore.MySql/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},

"dependencies": {
"Microsoft.EntityFrameworkCore.Relational": "1.0.1",
"Microsoft.EntityFrameworkCore.Relational": "1.1.0-preview1-final",
"MySqlConnector": "0.6.*",
"Pomelo.JsonObject": "1.0.0-*"
},
Expand Down
32 changes: 16 additions & 16 deletions test/Pomelo.EntityFrameworkCore.MySql.PerfTests/project.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"dependencies": {
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.1.0-preview1-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-preview1-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0-preview1-final",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0-preview1-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0-preview1-final",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.0-preview1-final",
"Microsoft.Extensions.Configuration.Json": "1.1.0-preview1-final",
"Microsoft.Extensions.Configuration.CommandLine": "1.1.0-preview1-final",
"Microsoft.Extensions.Logging": "1.1.0-preview1-final",
"Microsoft.Extensions.Logging.Console": "1.1.0-preview1-final",
"Microsoft.Extensions.Logging.Debug": "1.1.0-preview1-final",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0-preview1-final",
"Microsoft.EntityFrameworkCore.Design": {
"version": "1.0.0-preview2-final",
"version": "1.1.0-preview1-final",
"type": "build"
},
"MySql.Data.EntityFrameworkCore": "7.0.6-*",
"Pomelo.EntityFrameworkCore.MySql": {
"target": "project"
},
"xunit": "2.2.0-beta2-build3300"
"xunit": "2.2.0-beta3-build3402"
},

"testRunner": "xunit",

"tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-final"
},

"configurations": {
Expand All @@ -49,7 +49,7 @@
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
"version": "1.1.0-preview1-*"
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions test/Pomelo.EntityFrameworkCore.MySql.Tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
"testRunner": "xunit",
"dependencies": {
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Microsoft.EntityFrameworkCore": "1.0.1",
"Microsoft.EntityFrameworkCore.Relational": "1.0.1",
"Microsoft.EntityFrameworkCore.Relational.Specification.Tests": "1.0.1",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.EntityFrameworkCore": "1.1.0-preview1-final",
"Microsoft.EntityFrameworkCore.Relational": "1.1.0-preview1-final",
"Microsoft.EntityFrameworkCore.Relational.Specification.Tests": "1.1.0-preview1-final",
"Microsoft.Extensions.Logging": "1.1.0-preview1-final",
"Pomelo.EntityFrameworkCore.MySql": {
"target": "project"
},
"xunit": "2.2.0-beta2-build3300"
"xunit": "2.2.0-beta3-build3402"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
"version": "1.1.0-preview1-*"
}
}
}
Expand Down

0 comments on commit 0b5d1a6

Please sign in to comment.