EntityFrameworkCore.ClickHouse icon indicating copy to clipboard operation
EntityFrameworkCore.ClickHouse copied to clipboard

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

Open ktb-dev opened this issue 1 year ago • 1 comments

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.<PostSqlQueryAsync>d__54.MoveNext() at ClickHouse.Client.ADO.ClickHouseCommand.<ExecuteDbDataReaderAsync>d__53.MoveNext() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.<ExecuteReaderAsync>d__19.MoveNext() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.<ExecuteReaderAsync>d__19.MoveNext() at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.<ExecuteAsync>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?

ktb-dev avatar May 21 '23 19:05 ktb-dev

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

denis-ivanov avatar Apr 07 '24 14:04 denis-ivanov