-
-
Notifications
You must be signed in to change notification settings - Fork 71
Fix field evaluation in scaffolding #1133
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ | |
|
||
//$Authors = Jiri Cincura ([email protected]) | ||
|
||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using FirebirdSql.EntityFrameworkCore.Firebird.Scaffolding.Internal; | ||
using Microsoft.EntityFrameworkCore.Scaffolding; | ||
using NUnit.Framework; | ||
|
@@ -30,6 +32,81 @@ public void JustCanRun() | |
Assert.DoesNotThrow(() => modelFactory.Create(Connection, new DatabaseModelFactoryOptions())); | ||
} | ||
|
||
[Test] | ||
public async Task ReadsNullableCorrect() | ||
{ | ||
var tableName = "TEST_READS_IS_NULL_FROM_DOMAIN"; | ||
var columnNameNoDomainNull = "NO_DOMAIN_NULL"; | ||
var columnNameNoDomainNotNull = "NO_DOMAIN_NOT_NULL"; | ||
var columnNameDomainNull = "DOMAIN_NULL"; | ||
var columnNameDomainNotNull = "DOMAIN_NOT_NUL"; | ||
|
||
using var commandDomainNull = Connection.CreateCommand(); | ||
commandDomainNull.CommandText = "create domain DOMAIN_NULL as INTEGER"; | ||
await commandDomainNull.ExecuteNonQueryAsync(); | ||
|
||
using var commandDomainNotNull = Connection.CreateCommand(); | ||
commandDomainNotNull.CommandText = "create domain DOMAIN_NOT_NULL as INTEGER NOT NULL"; | ||
await commandDomainNotNull.ExecuteNonQueryAsync(); | ||
cincuranet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
using var commandTable = Connection.CreateCommand(); | ||
commandTable.CommandText = $"create table {tableName} ({columnNameNoDomainNull} INTEGER, {columnNameNoDomainNotNull} INTEGER NOT NULL, {columnNameDomainNull} DOMAIN_NULL, {columnNameDomainNotNull} DOMAIN_NOT_NULL)"; | ||
await commandTable.ExecuteNonQueryAsync(); | ||
cincuranet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
var modelFactory = GetModelFactory(); | ||
var model = modelFactory.Create(Connection.ConnectionString, new DatabaseModelFactoryOptions(new string[] { tableName })); | ||
var table = model.Tables.Single(x => x.Name == tableName); | ||
var columnNoDomainNull = table.Columns.Single(x => x.Name == columnNameNoDomainNull); | ||
var columnNoDomainNotNull = table.Columns.Single(x => x.Name == columnNameNoDomainNotNull); | ||
var columnDomainNull = table.Columns.Single(x => x.Name == columnNameDomainNull); | ||
var columnDomainNotNull = table.Columns.Single(x => x.Name == columnNameDomainNotNull); | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(columnNoDomainNull.IsNullable, Is.True); | ||
Assert.That(columnNoDomainNotNull.IsNullable, Is.False); | ||
Assert.That(columnDomainNull.IsNullable, Is.True); | ||
Assert.That(columnDomainNotNull.IsNullable, Is.False); | ||
}); | ||
|
||
} | ||
|
||
[TestCase("SMALLINT")] | ||
[TestCase("INTEGER")] | ||
[TestCase("FLOAT")] | ||
[TestCase("DATE")] | ||
[TestCase("TIME")] | ||
[TestCase("CHAR(12)")] | ||
[TestCase("BIGINT")] | ||
[TestCase("BOOLEAN")] | ||
[TestCase("DOUBLE PRECISION")] | ||
[TestCase("TIMESTAMP")] | ||
[TestCase("VARCHAR(24)")] | ||
[TestCase("BLOB SUB_TYPE TEXT")] | ||
[TestCase("BLOB SUB_TYPE BINARY")] | ||
[TestCase("DECIMAL(4,1)")] | ||
[TestCase("DECIMAL(9,1)")] | ||
[TestCase("DECIMAL(18,1)")] | ||
[TestCase("NUMERIC(4,1)")] | ||
[TestCase("NUMERIC(9,1)")] | ||
[TestCase("NUMERIC(18,1)")] | ||
public async Task ReadsCorrectFieldType(string dataType) | ||
{ | ||
var tableName = $"TEST_READS_FIELD_TYPE_CORRECT"; | ||
var columnName = "FIELD"; | ||
|
||
using var commandTable = Connection.CreateCommand(); | ||
commandTable.CommandText = $"recreate table {tableName} ({columnName} {dataType})"; | ||
await commandTable.ExecuteNonQueryAsync(); | ||
cincuranet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
var modelFactory = GetModelFactory(); | ||
var model = modelFactory.Create(Connection.ConnectionString, new DatabaseModelFactoryOptions(new string[] { tableName })); | ||
var table = model.Tables.Single(x => x.Name == tableName); | ||
var column = table.Columns.Single(x => x.Name == columnName); | ||
|
||
Assert.That(column.StoreType, Is.EqualTo(dataType)); | ||
} | ||
|
||
static IDatabaseModelFactory GetModelFactory() | ||
{ | ||
return new FbDatabaseModelFactory(); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.