Skip to content
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

[QP-8003] Insert Action에서 Not Null 제약조건 있는 컬럼에 값 지정 없을 시 에러 처리 #76

Merged
merged 4 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Qsi.Data.Object;
using Qsi.Data.Object.Function;
using Qsi.Engines;
using Qsi.PostgreSql.Data;
using Qsi.Utilities;

namespace Qsi.Tests.PostgreSql.Driver;
Expand Down Expand Up @@ -76,7 +77,7 @@ from information_schema.TABLES
}

sql = $@"
select COLUMN_NAME
select COLUMN_NAME, IS_NULLABLE, COLUMN_DEFAULT
from information_schema.COLUMNS
where TABLE_CATALOG = '{table.Identifier[0]}' and TABLE_SCHEMA = '{table.Identifier[1].Value}' and TABLE_NAME = '{table.Identifier[2].Value}'
order by ORDINAL_POSITION";
Expand All @@ -87,6 +88,8 @@ from information_schema.COLUMNS
{
var column = table.NewColumn();
column.Name = new QsiIdentifier(reader.GetString(0), false);
column.IsNullable = reader.GetString(1) == "YES";
column.Default = reader.IsDBNull(2) ? null : reader.GetString(2);
}
}

Expand Down
32 changes: 32 additions & 0 deletions Qsi.Tests/Vendor/PostgreSql/PostgreSqlTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,38 @@ public async Task Test_DML(string query, string[] expectedQueries, int expectedR
Assert.Pass();
}

/// <summary>
/// Insert Action 시 Not Null 제약조건 있는 테이블에 값 대입하는 상황에 관한 에러 처리를 확인하는 테스트를 수행합니다.
/// </summary>
[Test]
public async Task Test_InsertNotNull()
{
const string CreateTableQuery = @"create table if not exists test_not_null (
col1 VARCHAR NOT NULL,
col2 VARCHAR
)";

var command = Connection.CreateCommand();
command.CommandText = CreateTableQuery;
await command.ExecuteNonQueryAsync();

string[] queries =
{
"INSERT INTO test_not_null VALUES (null, 'test')",
"INSERT INTO test_not_null (col2) VALUES ('test')"
};

const string errorMessage = "QSI-0021: The column 'col1' has a Not Null constraint.";

foreach (var query in queries)
{
Assert.ThrowsAsync<QsiException>(async () =>
{
await Engine.Execute(new QsiScript(query, QsiScriptType.Insert), null);
}, errorMessage);
}
}

/// <summary>
/// Parameterized query에 대하여 테스트를 수행합니다.
/// </summary>
Expand Down
15 changes: 15 additions & 0 deletions Qsi/Analyzers/Action/QsiActionAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@
var script = new QsiScript(query, scriptType);
QsiParameter[] parameters = ArrangeBindParameters(context, commonTableNode);

return (await context.Engine.RepositoryProvider.GetDataTable(

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi/Qsi.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi/Qsi.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Redshift/Qsi.Redshift.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Trino/Qsi.Trino.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Trino/Qsi.Trino.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Athena/Qsi.Athena.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Athena/Qsi.Athena.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.SqlServer/Qsi.SqlServer.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.SqlServer/Qsi.SqlServer.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.PostgreSql/Qsi.PostgreSql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.MySql/Qsi.MySql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.MySql/Qsi.MySql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.PrimarSql/Qsi.PrimarSql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.PrimarSql/Qsi.PrimarSql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Cql/Qsi.Cql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Cql/Qsi.Cql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Impala/Qsi.Impala.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Impala/Qsi.Impala.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Hana/Qsi.Hana.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Hana/Qsi.Hana.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.PhoenixSql/Qsi.PhoenixSql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.PhoenixSql/Qsi.PhoenixSql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Debugger/Qsi.Debugger.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Oracle/Qsi.Oracle.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Oracle/Qsi.Oracle.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Debugger/Qsi.Debugger.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 448 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Tests/Qsi.Tests.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'
script,
parameters,
context.ExecuteOptions,
Expand All @@ -466,6 +466,10 @@
}

ColumnTarget[] columnTargets = await ResolveColumnTargetsFromDataInsertActionAsync(context, table, action);
var columnWithInvalidDefault = ResolveNotNullableColumnWithInvalidDefault(table.Columns, columnTargets);

if (columnWithInvalidDefault is not null)
throw new QsiException(QsiError.NotNullConstraints, columnWithInvalidDefault.Name.Value);

var dataContext = new TableDataInsertContext(context, table)
{
Expand Down Expand Up @@ -617,6 +621,14 @@
);
}

protected virtual QsiTableColumn ResolveNotNullableColumnWithInvalidDefault(IEnumerable<QsiTableColumn> columns, IEnumerable<ColumnTarget> columnTargets)
{
HashSet<string> targetNames = columnTargets.Select(ct => ct.DeclaredName.SubIdentifier(0).ToString()).ToHashSet();

return columns
.FirstOrDefault(x => !targetNames.Contains(x.Name.Value) && !x.IsNullable && x.Default is null);
}

private async ValueTask ProcessQueryValues(TableDataInsertContext context, IQsiTableDirectivesNode directives, IQsiTableNode valueTable)
{
var engine = context.Engine;
Expand All @@ -629,7 +641,7 @@
var scriptType = engine.ScriptParser.GetSuitableType(script);
QsiParameter[] parameters = ArrangeBindParameters(context, valueTable);

var dataTable = (await engine.RepositoryProvider.GetDataTable(

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi/Qsi.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi/Qsi.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Redshift/Qsi.Redshift.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Trino/Qsi.Trino.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Trino/Qsi.Trino.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Athena/Qsi.Athena.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Athena/Qsi.Athena.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.SqlServer/Qsi.SqlServer.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.SqlServer/Qsi.SqlServer.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.PostgreSql/Qsi.PostgreSql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.MySql/Qsi.MySql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.MySql/Qsi.MySql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.PrimarSql/Qsi.PrimarSql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.PrimarSql/Qsi.PrimarSql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Cql/Qsi.Cql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Cql/Qsi.Cql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Impala/Qsi.Impala.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Impala/Qsi.Impala.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Hana/Qsi.Hana.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Hana/Qsi.Hana.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.PhoenixSql/Qsi.PhoenixSql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.PhoenixSql/Qsi.PhoenixSql.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Debugger/Qsi.Debugger.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Oracle/Qsi.Oracle.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Oracle/Qsi.Oracle.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Debugger/Qsi.Debugger.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'

Check warning on line 644 in Qsi/Analyzers/Action/QsiActionAnalyzer.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp, ./Qsi.Tests/Qsi.Tests.csproj)

'IQsiRepositoryProvider.GetDataTable(QsiScript, QsiParameter[], ExecuteOptions, CancellationToken)' is obsolete: 'Use GetDataReader'
new QsiScript(script, scriptType),
parameters,
context.ExecuteOptions,
Expand Down Expand Up @@ -745,6 +757,9 @@
item = pivot.SourceColumn is not null
? valueSelector(pivot)
: ResolveDefaultColumnValue(pivot);

if (item.Value is null && target.Table.Columns[pivot.DestinationOrder].IsNullable == false)
throw new QsiException(QsiError.NotNullConstraints, pivot.DestinationColumn.Name.Value);
}

target.InsertRows.Add(targetRow);
Expand Down
3 changes: 3 additions & 0 deletions Qsi/Data/Table/QsiTableColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public bool IsExpression
set => _isExpression = value;
}

public bool IsNullable { get; set; } = true;

internal QsiQualifiedIdentifier ImplicitTableWildcardTarget { get; set; }

internal bool _isExpression;
Expand All @@ -52,6 +54,7 @@ internal QsiTableColumn CloneInternal()
column.ImplicitTableWildcardTarget = ImplicitTableWildcardTarget;
column._isExpression = _isExpression;
column.HasIndex = HasIndex;
column.IsNullable = IsNullable;

return column;
}
Expand Down
5 changes: 4 additions & 1 deletion Qsi/QsiError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public enum QsiError
ParameterNotFound,
InvalidNestedExplain,
SubqueryReturnsMoreThanRow,
UnableResolveFunction
UnableResolveFunction,
NotNullConstraints
}

internal static class SR
Expand Down Expand Up @@ -72,6 +73,7 @@ internal static class SR
public const string InvalidNestedExplain = "Invalid nested explain for '{0}'";
public const string SubqueryReturnsMoreThanRow = "Subquery returns more than {0} row";
public const string UnableResolveFunction = "Unable to resolve function '{0}'";
public const string NotNullConstraints = "The column '{0}' has a Not Null constraint.";

public static string GetResource(QsiError error)
{
Expand Down Expand Up @@ -110,6 +112,7 @@ public static string GetResource(QsiError error)
QsiError.InvalidNestedExplain => InvalidNestedExplain,
QsiError.SubqueryReturnsMoreThanRow => SubqueryReturnsMoreThanRow,
QsiError.UnableResolveFunction => UnableResolveFunction,
QsiError.NotNullConstraints => NotNullConstraints,
_ => null
};
}
Expand Down
Loading