Fix smaller issues and add TODOs.

pull/47/head
Lau 6 years ago
parent bdfbafa5f7
commit 0df985e00d

@ -364,6 +364,12 @@ namespace Microsoft.EntityFrameworkCore.Migrations
Check.NotNull(operation, nameof(operation));
Check.NotNull(builder, nameof(builder));
// CHECK: Rename table operations require extensions like ADOX or DAO.
// A native way to do this would be to:
// 1. CREATE TABLE `destination table`
// 2. INSERT INTO ... SELECT ... FROM
// 3. DROP TABLE `source table`
// 4. Recrete indices and references.
builder.Append("RENAME TABLE ")
.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Name))
.Append(" TO ")

@ -24,6 +24,8 @@ namespace System.Data.Jet
}
catch (Exception e)
{
// TODO: Try interating over the _Tables collection instead of using Item["TableName"].
throw new Exception("Cannot rename table", e);
}
finally
@ -48,7 +50,8 @@ namespace System.Data.Jet
try
{
using var tables = catalog.Tables;
using var columns = tables[tableName].Columns;
using var table = tables[tableName];
using var columns = table.Columns;
using var column = columns[columnName];
column.Name = newColumnName;
}
@ -92,8 +95,7 @@ namespace System.Data.Jet
connection.DataAccessProviderFactory = dataAccessProviderFactory;
connection.Open();
string sql = @"
CREATE TABLE `MSysAccessStorage` (
var sql = @"CREATE TABLE `MSysAccessStorage` (
`DateCreate` DATETIME NULL,
`DateUpdate` DATETIME NULL,
`Id` COUNTER NOT NULL,
@ -136,9 +138,9 @@ CREATE UNIQUE INDEX `ParentIdName` ON `MSysAccessStorage` (`ParentId`, `Name`);"
try
{
using dynamic cnn = new ComObject("ADODB.Connection");
cnn.Open(connectionString);
catalog.ActiveConnection = cnn;
using dynamic connection = new ComObject("ADODB.Connection");
connection.Open(connectionString);
catalog.ActiveConnection = connection;
}
catch (Exception e)
{

@ -110,7 +110,7 @@ namespace System.Data.Jet
public void Dispose()
{
// The RCW is a .NET object and cannot be released from the finalizer anymore,
// The RCW is a .NET object and cannot be released from the finalizer,
// because it might not exist anymore.
if (_instance != null)
{

@ -489,6 +489,9 @@ namespace System.Data.Jet
public void CreateEmptyDatabase()
=> CreateEmptyDatabase(DataSource, DataAccessProviderFactory);
// TODO: Use the `CREATE_DB` connection string option instead of calling ADOX when using ODBC, to create
// a new database file.
// Alternatively, use DAO in conjunction with ODBC.
public static string CreateEmptyDatabase(string fileNameOrConnectionString, DbProviderFactory dataAccessProviderFactory)
=> AdoxWrapper.CreateEmptyDatabase(fileNameOrConnectionString, dataAccessProviderFactory);

@ -22,7 +22,10 @@ namespace System.Data.Jet.JetStoreSchemaDefinition
{
string tableName = match.Groups["tableName"].Value;
string newTableName = match.Groups["newTableName"].Value;
// TODO: Only use ADOX in an OLE DB context. Use DAO in an ODBC context.
AdoxWrapper.RenameTable(connectionString, RemoveBrackets(tableName), RemoveBrackets(newTableName));
return true;
}

Loading…
Cancel
Save