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

Test for FullAuditedEntity<T> base class #2838

Closed
hikalkan opened this issue Feb 16, 2020 · 11 comments
Closed

Test for FullAuditedEntity<T> base class #2838

hikalkan opened this issue Feb 16, 2020 · 11 comments
Assignees
Milestone

Comments

@hikalkan
Copy link
Member

A developer reported that using FullAuditedEntity<Guid> as the base class instead of the FullAuditedAggregateRoot<Guid> causes problems in the tutorial.

@hikalkan
Copy link
Member Author

Error details:

2020-02-12 00:31:08.661 +03:00 [ERR] An error occurred while updating the entries. See the inner exception for details.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
 ---> Npgsql.PostgresException (0x80004005): 23502: null value in column "IsDeleted" violates not-null constraint
   at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming)
   at Npgsql.NpgsqlCommand.ExecuteReaderAsync(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
   at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
  Exception data:
    Severity: ERROR
    SqlState: 23502
    MessageText: null value in column "IsDeleted" violates not-null constraint
    Detail: Failing row contains (e1e1cf31-9303-0549-290b-39f348568ebd, 2020-02-12 00:31:08.523289, c047c028-fc6b-6837-20b2-39f2fad2df9c, null, null, null, null, null, 1, Tübitak 1001, 1, 1, 80, t).
    SchemaName: public
    TableName: AcdPerfCategory
    ColumnName: IsDeleted
    File: d:\pginstaller_12.auto\postgres.windows-x64\src\backend\executor\execmain.c
    Line: 1974
    Routine: ExecConstraints

It is something related to the IsDeleted field. This error log is for PostgreSQL.

@yekalkan
Copy link
Member

instead of the FullAuditedAggregateRoot

FullAuditedAggregateRoot is not used in tutorial?

image

@hikalkan
Copy link
Member Author

OK, so go with AuditedEntity.

@yekalkan
Copy link
Member

I haven't encountered this problem.

I have followed the tutorial, made base class FullAuditedEntity and used postgresql.

@yekalkan
Copy link
Member

No problem with AuditedEntity as well.

@leonkosak
Copy link
Contributor

leonkosak commented Feb 27, 2020

@yekalkan, @hikalkan I can also confirm this issue (abp v2.1.1) with Postgres.
My entity inherits from FullAuditedEntity< long >, IMultiTenant.

Message:
Npgsql.PostgresException (0x80004005): 23502: null value in column "IsDeleted" violates not-null constraint

I also tried manually set IsDeleted property, but the result was the same.

@maliming
Copy link
Member

@leonkosak I will try with Postgres.

@maliming maliming reopened this Feb 27, 2020
@maliming
Copy link
Member

hi @leonkosak

I created an aggregate root and inserted some data, which did not reproduce your problem.

PostgreSQL 12.2 (Debian 12.2-2.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit

await _questionsRepository.InsertAsync(new Question(GuidGenerator.Create(), "test"));
public class Question : FullAuditedAggregateRoot<Guid>
{
	public virtual string Name { get; protected set; }

	protected Question()
	{
		
	}

	public Question(Guid id, [NotNull] string name)
	{
		Id = id;
		Name = Check.NotNullOrWhiteSpace(name, nameof(name));
	}
}

@leonkosak
Copy link
Contributor

@maliming Ok, thank you. This solves my issue.
However, what is the reason that I have to inherit from AggregateRoot? Yes, the entity is not owned (as list/collection of children) in any other sql table.

I also noticed that TenantId property is null in sql table record even the CurrentTenant (ICurrentTenant) has tenant info stored. This tenant is in separated database, but as far as I know for abp-related tables, there should have been tenantid guid value present (if tenantid is not present, there is strange error when logging to this tenant in the web app).
Shoul I manually assigned tenantid value or this is not required for my custom tables (related to my application)?

@geffzhang
Copy link

FullAuditedAggregateRoot also occurred (abp v2.9) with Postgres.

@maliming
Copy link
Member

maliming commented Jul 6, 2020

@geffzhang Please create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants