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

Bug: PostgreSQL BinaryBulkMerge not working when table has name "schema.table" #1132

Open
Mewriick opened this issue Feb 10, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@Mewriick
Copy link

Hello,

I try to pefrom BulkMerge on PostgreSQL, but I receive error message.

SQL Error [3F000]: ERROR: schema "_RepoDb_BinaryBulkMerge_configuration" does not exist
The problem is when RepoDb is try to create Temp table

   at Npgsql.Internal.NpgsqlConnector.<<ReadMessage>g__ReadMessageLong|226_0>d.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Npgsql.NpgsqlDataReader.<NextResult>d__47.MoveNext()
   at Npgsql.NpgsqlDataReader.<NextResult>d__47.MoveNext()
   at Npgsql.NpgsqlCommand.<ExecuteReader>d__124.MoveNext()
   at Npgsql.NpgsqlCommand.<ExecuteReader>d__124.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Npgsql.NpgsqlCommand.<ExecuteNonQuery>d__112.MoveNext()
   at RepoDb.DbConnectionExtension.<ExecuteNonQueryAsyncInternal>d__26.MoveNext()
   at RepoDb.NpgsqlConnectionExtension.<CreatePseudoTableAsync>d__86.MoveNext()
   at RepoDb.NpgsqlConnectionExtension.<PseudoBasedBinaryImportAsync>d__131.MoveNext()
   at RepoDb.NpgsqlConnectionExtension.<PseudoBasedBinaryImportAsync>d__131.MoveNext()
   at RepoDb.NpgsqlConnectionExtension.<BinaryBulkMergeBaseAsync>d__17`1.MoveNext()
   at RepoDb.NpgsqlConnectionExtension.<BinaryBulkMergeAsync>d__162`1.MoveNext()

Mapping

FluentMapper
	.Entity<Account>()
	.Table("configuration.account")
	.Primary(account => account.Id)
	.Identity(account => account.Id);

Used operation

var mergedRows = await connection.BinaryBulkMergeAsync(
  accounts,
  qualifiers: new List<Field> { new Field(nameof(Account.AccountNumber)) },
  mergeCommandType: RepoDb.Enumerations.PostgreSql.BulkImportMergeCommandType.OnConflictDoUpdate,
  //transaction: transaction,
  cancellationToken: cancellationToken);

Here is generated SQL for creating Temp table

SELECT "colums...." INTO TEMPORARY 
"_RepoDb_BinaryBulkMerge_configuration"."account" FROM "configuration"."account" WHERE (1 = 0);

I believe that the problem here is that there are quotes separated by comma. If I use this SQL everythink is working

SELECT "Id", "AccountNumber", "Status", "CgLevel", "Email", "Hwm"
INTO TEMPORARY "_RepoDb_BinaryBulkMerge_configuration.account" FROM "configuration"."account" WHERE (1 = 0);

Can you please help me, If I am doing something wrong with configuration?

Library Version:

Example: RepoDb v1.13.0 and RepoDb.PostgreSql.BulkOperation v1.13.0

@Mewriick Mewriick added the bug Something isn't working label Feb 10, 2023
@mikependon
Copy link
Owner

No, there is no problem from your side. It sounds to me that RepoDB SQL Builder has built an invalid SQL statement during data staging. We will look and fix this problem soon. Thanks for reporting this issue.

SergerGood added a commit that referenced this issue Mar 15, 2023
@mikependon
Copy link
Owner

@SergerGood - I have never validated your fix yet, I will keep this one open for now. But, I will do revisit ASAP and cover this in the next release.

@mikependon mikependon pinned this issue Mar 16, 2023
@jbrezina
Copy link

Any updates on this please @mikependon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants