Skip to content
Open
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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ tab_width = 4
# New line preferences
insert_final_newline = false

[*.csproj]
indent_size = 2
tab_width = 2

#### .NET Coding Conventions ####
[*.{cs,vb}]

Expand Down
51 changes: 51 additions & 0 deletions EntityFrameworkCore.ClickHouse.FunctionalTests/ProviderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using ClickHouse.Driver.ADO;
using System.Data;
using Xunit;

namespace EntityFrameworkCore.ClickHouse.FunctionalTests;

public class ProviderTests
{
[Fact]
public void Fact()
{
const string connectionStringBase = "Host=localhost;Protocol=http;Port=8123;Username=default;Password=changeme";

var connection = new ClickHouseConnection(connectionStringBase);
connection.SetFormDataParameters(true);

var command = connection.CreateCommand();
command.CommandText = """
CREATE DATABASE IF NOT EXISTS array_with_null_item;
""";

connection.Open();
command.ExecuteNonQuery();
connection.Close();

connection.ConnectionString = $"{connectionStringBase};Database=array_with_null_item";
connection.Open();

command.CommandText = """
CREATE TABLE IF NOT EXISTS my_table
(
Id Int32,
Value Array(Nullable(String))
)
ENGINE = MergeTree()
ORDER BY Id;
""";
command.ExecuteNonQuery();

command.CommandText = "INSERT INTO my_table VALUES (1, {p0:Array(Nullable(String))})";
var array = new string[] { "1", "2", "3", null };
var arrayParameter = command.CreateParameter();
arrayParameter.ParameterName = "p0";
arrayParameter.Value = array;
arrayParameter.DbType = DbType.Object;
arrayParameter.ClickHouseType = "Array(Nullable(String))";
command.Parameters.Add(arrayParameter);

command.ExecuteNonQuery();
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using EntityFrameworkCore.ClickHouse.FunctionalTests.TestModels.Array;
using EntityFrameworkCore.ClickHouse.FunctionalTests.TestUtilities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.EntityFrameworkCore.TestUtilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;

namespace EntityFrameworkCore.ClickHouse.FunctionalTests.Query;

public abstract class ArrayQueryFixture : SharedStoreFixtureBase<ArrayQueryContext>, IQueryFixtureBase, ITestSqlLoggerFactory
{
protected override ITestStoreFactory TestStoreFactory
=> ClickHouseTestStoreFactory.Instance;

public TestSqlLoggerFactory TestSqlLoggerFactory
=> (TestSqlLoggerFactory)ListLoggerFactory;

private ArrayQueryData _expectedData;

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
=> base.AddOptions(builder).ConfigureWarnings(wcb => wcb.Ignore(CoreEventId.CollectionWithoutComparer));

protected override Task SeedAsync(ArrayQueryContext context)
=> ArrayQueryContext.SeedAsync(context);

public Func<DbContext> GetContextCreator()
=> CreateContext;

public ISetSource GetExpectedData()
=> _expectedData ??= new ArrayQueryData();

public IReadOnlyDictionary<Type, object> EntitySorters
=> new Dictionary<Type, Func<object, object>>
{
{ typeof(ArrayEntity), e => ((ArrayEntity)e)?.Id }
}.ToDictionary(e => e.Key, e => (object)e.Value);

public IReadOnlyDictionary<Type, object> EntityAsserters
=> new Dictionary<Type, Action<object, object>>
{
{
typeof(ArrayEntity), (e, a) =>
{
Assert.Equal(e is null, a is null);
if (a is not null)
{
var ee = (ArrayEntity)e;
var aa = (ArrayEntity)a;

Assert.Equal(ee.Id, aa.Id);
Assert.Equal(ee.IntArray, ee.IntArray);
Assert.Equal(ee.IntList, ee.IntList);
Assert.Equal(ee.NullableIntArray, ee.NullableIntArray);
Assert.Equal(ee.Bytea, ee.Bytea);
Assert.Equal(ee.ByteArray, ee.ByteArray);
Assert.Equal(ee.StringArray, ee.StringArray);
Assert.Equal(ee.StringList, ee.StringList);
Assert.Equal(ee.NullableStringArray, ee.NullableStringArray);
Assert.Equal(ee.NullableStringList, ee.NullableStringList);
Assert.Equal(ee.NullableText, ee.NullableText);
Assert.Equal(ee.NonNullableText, ee.NonNullableText);
Assert.Equal(ee.EnumConvertedToInt, ee.EnumConvertedToInt);
Assert.Equal(ee.ArrayOfStringConvertedToDelimitedString, ee.ArrayOfStringConvertedToDelimitedString);
Assert.Equal(ee.ListOfStringConvertedToDelimitedString, ee.ListOfStringConvertedToDelimitedString);
Assert.Equal(ee.ValueConvertedArrayOfEnum, ee.ValueConvertedArrayOfEnum);
Assert.Equal(ee.ValueConvertedListOfEnum, ee.ValueConvertedListOfEnum);
Assert.Equal(ee.IList, ee.IList);
Assert.Equal(ee.Byte, ee.Byte);
}
}
}
}.ToDictionary(e => e.Key, e => (object)e.Value);
}
Loading
Loading