SeaQL/sea-orm

Issues with tables that do not have primary/unique keys

gitmalong opened this issue · 1 comments

Hi!

When creating a table that does not have a primary key attached

1) Not able to create table that do not has primary key

Workarounds in #485 do not work. Using a unique col instead does also not work in my use case with pg_partman (Execution Error: error returned from database: unique constraint on partitioned table must include all partitioning columns).

Motivation: I am trying to make use of https://github.com/pgpartman/pg_partman/blob/master/doc/pg_partman_howto.md#simple-time-based-1-partition-per-day which wants me to create a parent table without having a primary key.

2) Compile errors with misleading error messages

Expected behavior:

5  | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
   |                                   ^^^^^^^^^^^^^^^^^ the trait `sea_orm::IdenStatic` is not implemented for `entities::table_without_primary_key::PrimaryKey`

Actual behavior:

I am getting misleading error messages for tables that have primary keys and were not modified.

5  | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
   |                                   ^^^^^^^^^^^^^^^^^ the trait `sea_orm::IdenStatic` is not implemented for `entities::table_with_primary_key::PrimaryKey`

I found that seaorm cli for does not add #[sea_orm(primary_key)] to all tables when one of the tables is lacking of a primary key.