Skip to content

Commit 5010b3d

Browse files
committed
Implementations of obsolete Extractor.ExtractSchema method became obsolete
1 parent 976f199 commit 5010b3d

File tree

6 files changed

+82
-24
lines changed

6 files changed

+82
-24
lines changed

Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v2_5/Extractor.cs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2011-2021 Xtensive LLC.
1+
// Copyright (C) 2011-2023 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Csaba Beer
@@ -24,15 +24,15 @@ internal partial class Extractor : Model.Extractor
2424
private Catalog theCatalog;
2525
private string targetSchema;
2626

27+
/// <inheritdoc/>
2728
public override Catalog ExtractCatalog(string catalogName)
2829
{
29-
theCatalog = new Catalog(catalogName);
30-
targetSchema = null;
31-
ExtractSchemas();
32-
ExtractCatalogContents();
30+
theCatalog = ExtractSchemes(catalogName, Array.Empty<string>());
3331
return theCatalog;
3432
}
3533

34+
/// <inheritdoc/>
35+
[Obsolete]
3636
public override Schema ExtractSchema(string catalogName, string schemaName)
3737
{
3838
theCatalog = new Catalog(catalogName);
@@ -43,6 +43,19 @@ public override Schema ExtractSchema(string catalogName, string schemaName)
4343
// return theCatalog.Schemas[targetSchema];
4444
}
4545

46+
/// <inheritdoc/>
47+
public override Catalog ExtractSchemes(string catalogName, string[] schemaNames)
48+
{
49+
ArgumentValidator.EnsureArgumentNotNullOrEmpty(catalogName, nameof(catalogName));
50+
ArgumentValidator.EnsureArgumentNotNull(schemaNames, nameof(schemaNames));
51+
52+
var targetSchema = schemaNames.Length > 0 ? schemaNames[0] : null;
53+
theCatalog = new Catalog(catalogName);
54+
ExtractSchemas(theCatalog, targetSchema);
55+
ExtractCatalogContents();
56+
return theCatalog;
57+
}
58+
4659
private void ExtractCatalogContents()
4760
{
4861
ExtractTables();
@@ -56,11 +69,18 @@ private void ExtractCatalogContents()
5669
ExtractSequences();
5770
}
5871

59-
private void ExtractSchemas()
72+
private void ExtractSchemas(Catalog catalog, string targetSchema)
6073
{
61-
var defaultSchemaName = Driver.CoreServerInfo.DefaultSchemaName.ToUpperInvariant();
62-
var defaultSchema = theCatalog.CreateSchema(defaultSchemaName);
63-
theCatalog.DefaultSchema = defaultSchema;
74+
if (targetSchema == null) {
75+
var defaultSchemaName = Driver.CoreServerInfo.DefaultSchemaName.ToUpperInvariant();
76+
var defaultSchema = catalog.CreateSchema(defaultSchemaName);
77+
catalog.DefaultSchema = defaultSchema;
78+
}
79+
else {
80+
// since target schema is the only schema to extract
81+
// it will be set as default for catalog
82+
_ = catalog.CreateSchema(targetSchema);
83+
}
6484
}
6585

6686
private void ExtractTables()

Orm/Xtensive.Orm.MySql/Sql.Drivers.MySql/v5_0/Extractor.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2011-2023 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Malisa Ncube
55
// Created: 2011.02.25
66

@@ -30,11 +30,11 @@ public override Catalog ExtractCatalog(string catalogName)
3030
theCatalog = new Catalog(catalogName);
3131
targetSchema = null;
3232
RegisterReplacements(replacementsRegistry);
33-
var schema = ExtractSchema(string.Empty, Driver.CoreServerInfo.DefaultSchemaName);
34-
return schema.Catalog;
33+
return ExtractSchemes(string.Empty, new string[] { Driver.CoreServerInfo.DefaultSchemaName });
3534
}
3635

3736
/// <inheritdoc/>
37+
[Obsolete]
3838
public override Schema ExtractSchema(string catalogName, string schemaName)
3939
{
4040
theCatalog = new Catalog(catalogName);
@@ -45,6 +45,22 @@ public override Schema ExtractSchema(string catalogName, string schemaName)
4545
return result;
4646
}
4747

48+
/// <inheritdoc/>
49+
public override Catalog ExtractSchemes(string catalogName, string[] schemaNames)
50+
{
51+
theCatalog = new Catalog(catalogName);
52+
if (schemaNames?.Length == 0) {
53+
targetSchema = null;
54+
}
55+
else {
56+
targetSchema = schemaNames[0];
57+
}
58+
var result = theCatalog.CreateSchema(targetSchema);
59+
RegisterReplacements(replacementsRegistry);
60+
ExtractCatalogContents();
61+
return theCatalog;
62+
}
63+
4864
private void ExtractCatalogContents()
4965
{
5066
ExtractTables();

Orm/Xtensive.Orm.Oracle/Sql.Drivers.Oracle/v09/Extractor.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2009-2023 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov
55
// Created: 2009.07.17
66

@@ -30,6 +30,7 @@ internal partial class Extractor : Model.Extractor
3030

3131
private string nonSystemSchemasFilter;
3232

33+
/// <inheritdoc/>
3334
public override Catalog ExtractCatalog(string catalogName)
3435
{
3536
theCatalog = new Catalog(catalogName);
@@ -41,6 +42,8 @@ public override Catalog ExtractCatalog(string catalogName)
4142
return theCatalog;
4243
}
4344

45+
/// <inheritdoc/>
46+
[Obsolete]
4447
public override Schema ExtractSchema(string catalogName, string schemaName)
4548
{
4649
targetSchemes.Clear();
@@ -55,6 +58,7 @@ public override Schema ExtractSchema(string catalogName, string schemaName)
5558
return theCatalog.Schemas[targetSchema];
5659
}
5760

61+
/// <inheritdoc/>
5862
public override Catalog ExtractSchemes(string catalogName, string[] schemaNames)
5963
{
6064
theCatalog = new Catalog(catalogName);

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0/Extractor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2003-2020 Xtensive LLC.
1+
// Copyright (C) 2003-2023 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44

@@ -293,6 +293,7 @@ protected virtual void BuildPgCatalogSchema(Schema schema)
293293

294294
#endregion
295295

296+
/// <inheritdoc/>
296297
public override Catalog ExtractCatalog(string catalogName)
297298
{
298299
var catalog = new Catalog(catalogName);
@@ -302,6 +303,8 @@ public override Catalog ExtractCatalog(string catalogName)
302303
return catalog;
303304
}
304305

306+
/// <inheritdoc/>
307+
[Obsolete]
305308
public override Schema ExtractSchema(string catalogName, string schemaName)
306309
{
307310
var catalog = new Catalog(catalogName);
@@ -313,6 +316,7 @@ public override Schema ExtractSchema(string catalogName, string schemaName)
313316
return result;
314317
}
315318

319+
/// <inheritdoc/>
316320
public override Catalog ExtractSchemes(string catalogName, string[] schemaNames)
317321
{
318322
var catalog = new Catalog(catalogName);

Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/v09/Extractor.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2009-2023 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Dmitri Maximov
55
// Created: 2009.08.11
66

@@ -33,13 +33,16 @@ internal class Extractor : Model.Extractor
3333
protected HashSet<string> targetSchemes = new HashSet<string>();
3434
//protected Dictionary<string, Schema> targetSchemes = new Dictionary<string, Schema>();
3535

36+
/// <inheritdoc/>
3637
public override Catalog ExtractCatalog(string catalogName)
3738
{
3839
catalog = new Catalog(catalogName);
3940
ExtractCatalogContents();
4041
return catalog;
4142
}
4243

44+
/// <inheritdoc/>
45+
[Obsolete]
4346
public override Schema ExtractSchema(string catalogName, string schemaName)
4447
{
4548
catalog = new Catalog(catalogName);
@@ -48,6 +51,7 @@ public override Schema ExtractSchema(string catalogName, string schemaName)
4851
return catalog.Schemas[schemaName];
4952
}
5053

54+
/// <inheritdoc/>
5155
public override Catalog ExtractSchemes(string catalogName, string[] schemaNames)
5256
{
5357
catalog = new Catalog(catalogName);

Orm/Xtensive.Orm.Sqlite/Sql.Drivers.Sqlite/v3/Extractor.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2011-2023 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Malisa Ncube
55
// Created: 2011.04.29
66

@@ -35,6 +35,7 @@ public override Catalog ExtractCatalog(string catalogName)
3535
}
3636

3737
/// <inheritdoc/>
38+
[Obsolete]
3839
public override Schema ExtractSchema(string catalogName, string schemaName)
3940
{
4041
catalog = new Catalog(catalogName);
@@ -43,6 +44,15 @@ public override Schema ExtractSchema(string catalogName, string schemaName)
4344
return catalog.Schemas.Single();
4445
}
4546

47+
/// <inheritdoc/>
48+
public override Catalog ExtractSchemes(string catalogName, string[] schemaNames)
49+
{
50+
catalog = new Catalog(catalogName);
51+
schema = catalog.CreateSchema(schemaNames[0]);
52+
ExtractCatalogContents();
53+
return catalog;
54+
}
55+
4656
private void ExtractCatalogContents()
4757
{
4858
ExtractTables();

0 commit comments

Comments
 (0)