-
Notifications
You must be signed in to change notification settings - Fork 1
/
DefaultSchema.txt
76 lines (55 loc) · 3.02 KB
/
DefaultSchema.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Default schema usage
--------------------
MsSql: Default schema is "dbo".
Oracle: Default schema is the user name.
SqLite: no schemas.
MySQL: no schemas.
PostgreSQL: Default schema is "public".
(Current) configuration/set points:
-----------------------------------
- Common.Helper.GetDefaultSettings:
sqlDialectSpecificSettings["DefaultSchema"] = "dbo"
- TestBase.TestHelper.GetDefaultTestSettings
calls Common.Helper.GetDefaultSettings, plus:
if Oracle
"DefaultSchema" is constructed from the (test) assembly name
Reasoning: In the case of Oracle database is NOT CREATED,
schema is created instead, and the Oracle Executer will create the defaultSchema (as User) in InitializeDatabase.
CleanupDatabase will delete schema (DROP USER)
- Options.ShouldUseDefaultSchema
DocumentHelper.GetSimplifiedSchemaAndTableName injects sqlDialectSpecificSettings["DefaultSchema"] as schema if
ShouldUseDefaultSchema is true and provided schema part is null.
GenericSqlGenerator.GetSimplifiedSchemaAndTableName uses sqlDialectSpecificSettings["DefaultSchema"] as schema if
ShouldUseDefaultSchema is true and provided schema part is null - using GuardKeywords, so for exampl, in the form of [schema].[tableName] or [tableName].
Note:
- Common.Helper.GetDefaultSettings:
sqlDialectSpecificSettings["OracleDatabaseName"] = configuration["oracleDatabaseName"]
This database name is used in OracleExecuter.GetDatabase()
MsSqlExecuter uses GetDatabase() with Create and Drop database.
In case of OracleExecuter, GetDatabase() is only used for logging purposes (No db creation/drop in case of Oracle).
Expected behaviour:
-------------------
Creation
--------
MsSql: if no schema is provided, use DefaultSchema.
The sql engine will work accordingly, creating object in "dbo".
Oracle: if no schema is provided, use DefaultSchema.
The sql engine will work accordingly, creating object in the nam of the current user.
No schemas (SqLite, MySQL): SchemaAndTableName should not contain schema part.
If does, exception should occur.
// TODO maybe use Feature flag.
SchemaAndTableName equality.
SchemaAndTableName is SqlDialect independent, so does not and should not be dependent about any SqlDialectSpecificSettings including "DefaultSchema".
Thus two SchemaAndTableName are only equal if schema and tableName parts are equal.
Reader
------
When reading the database structure, we don't know, if default schema was used or not.
While this is fix in case of MsSql ("dbo"), in Oracle, this might change (current user = current schema).
Current (as of 01/07/2020) issue.
- Create (a schemaless) DataBaseDefinition with no schema.
At this step, schema parts in SchemaAndTableName are null.
- Create database
Default behaviour will create the tables with the DefaultSchema.
("dbo" in MsSql, the current user in Oracle, and no schema in engines without schema feature.
- Now when DataDefinitionReader reads the structure of the created database, it does fill up schema parts in SchemaAndTableName
Now original.Table.SchemaAndTableName <> readBack Table.SchemaAndTableName.