And then I try to insert it
\nvar dbTag = new DbTransactionTag\n{\n TagId = tag.Id,\n TransactionId = transaction.Id, // This is 100% not null, I've checked multiple scenarios with the debugger\n UserId = UserId\n};\n\nawait supabase.From<DbTransactionTag>().Insert(dbTag, minimalQueryOptions, cancellationToken);
But no matter what, I just get
\nSupabase.Postgrest.Exceptions.PostgrestException: {\"code\":\"23502\",\"details\":null,\"hint\":null,\"message\":\"null value in column \\\"transaction_id\\\" of relation \\\"transaction_tags\\\" violates not-null constraint\"}
Am I missing something obvious here? I'm clearly setting the transaction_id
field.
I managed to solve it by changing PrimaryKey(\"\")
to PrimaryKey(\"\", true)
. There's a hidden shouldInsert
parameter there that should be true.
So my class would be
\n[Table(\"transaction_tags\")]\ninternal sealed class DbTransactionTag : BaseModel\n{\n- [PrimaryKey(\"transaction_id\")]\n+ [PrimaryKey(\"transaction_id\", true)]\n public Guid TransactionId { get; set; }\n- [PrimaryKey(\"tag_id\")]\n+ [PrimaryKey(\"tag_id\", true)]\n public Guid TagId { get; set; }\n [Column(\"user_id\")]\n public Guid UserId { get; set; }\n}
-
I have a table on Supabase with 3 columns:
Then in my class [Table("transaction_tags")]
internal sealed class DbTransactionTag : BaseModel
{
[PrimaryKey("transaction_id")]
public Guid TransactionId { get; set; }
[PrimaryKey("tag_id")]
public Guid TagId { get; set; }
[Column("user_id")]
public Guid UserId { get; set; }
} And then I try to insert it var dbTag = new DbTransactionTag
{
TagId = tag.Id,
TransactionId = transaction.Id, // This is 100% not null, I've checked multiple scenarios with the debugger
UserId = UserId
};
await supabase.From<DbTransactionTag>().Insert(dbTag, minimalQueryOptions, cancellationToken); But no matter what, I just get Am I missing something obvious here? I'm clearly setting the |
Beta Was this translation helpful? Give feedback.
-
I managed to solve it by changing So my class would be [Table("transaction_tags")]
internal sealed class DbTransactionTag : BaseModel
{
- [PrimaryKey("transaction_id")]
+ [PrimaryKey("transaction_id", true)]
public Guid TransactionId { get; set; }
- [PrimaryKey("tag_id")]
+ [PrimaryKey("tag_id", true)]
public Guid TagId { get; set; }
[Column("user_id")]
public Guid UserId { get; set; }
} |
Beta Was this translation helpful? Give feedback.
I managed to solve it by changing
PrimaryKey("")
toPrimaryKey("", true)
. There's a hiddenshouldInsert
parameter there that should be true.So my class would be