denis-ivanov / EntityFrameworkCore.ClickHouse

ClickHouse provider for Entity Framework Core.
https://clickhouse.tech/
23 stars 5 forks source link

A very long value in a string. Invalid URI: The Uri string is too long. #23

Closed ktb-dev closed 6 months ago

ktb-dev commented 1 year ago
class MyTable
{
       public string Txt => "a very very long value .........";
}

var item = new MyTable();

var _dbSet = _dbContext.Set<MyTable>();
await _dbSet.AddAsync(item);
await _dbContext.SaveChangesAsync();

when I use EntityFramework, and I try to insert an object into the table that has a string type property and this property has a very long value, then I get this error:

exception.InnerException.Message => Invalid URI: The Uri string is too long.

exception.InnerException.StackTrace =>

_at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions) at System.Uri..ctor(String uriString, UriKind uriKind) at System.Net.Http.HttpRequestMessage..ctor(HttpMethod method, String requestUri) at ClickHouse.Client.ADO.ClickHouseCommand.d54.MoveNext() at ClickHouse.Client.ADO.ClickHouseCommand.d53.MoveNext() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.d19.MoveNext() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.d19.MoveNext() at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.d_50.MoveNext()

but, if you use this method, then everything works out successfully:

using var bulkCopy = new ClickHouseBulkCopy(connection)
{
      DestinationTableName = "mytable",
      BatchSize = 1
};

var list = (new List<object[]>() { new object[] { item.Txt } });
await bulkCopy.WriteToServerAsync(list);

as I understand it, this method generates the following query:

INSERT INTO {DestinationTableName} ({string.Join(", ", columnNames)}) FORMAT RowBinary;

is there a way to execute a query using ORM?

denis-ivanov commented 7 months ago

Please, try a new version EntityFrameworkCore.ClickHouse/0.0.14 and if it's still reproducible provide a minimum working example.