sqlboiler icon indicating copy to clipboard operation
sqlboiler copied to clipboard

Partition Table Unable To Generate Relationships

Open magicMustard opened this issue 3 years ago • 5 comments

If you're having a generation problem please answer these questions before submitting your issue. Thanks!

What version of SQLBoiler are you using (sqlboiler --version)?

SQLBoiler v4.10.2

What is your database and version (eg. Postgresql 10)

psql (PostgreSQL) 13.6 (Debian 13.6-1.pgdg100+1)

Please provide a relevant database schema so we can replicate your issue (Provided you are comfortable sharing this)

CREATE TABLE field_entity_values ( account_id CHARACTER(26) NOT NULL, entity_type ENTITY_TYPE NOT NULL, entity_id CHARACTER(26) NOT NULL, field_type FIELD_TYPE NOT NULL, field_id CHARACTER(26) NOT NULL, idx_value_id CHARACTER(26) DEFAULT NULL, value_id CHARACTER(26) DEFAULT NULL, PRIMARY KEY (account_id, entity_type, entity_id, field_type, field_id), CONSTRAINT FK_FIELD_ENTITY_VALUES_ENTITY_ID FOREIGN KEY (entity_id) REFERENCES entities(id), CONSTRAINT FK_FIELD_ENTITY_VALUES_FIELD_ID FOREIGN KEY (field_id) REFERENCES fields(id) ) PARTITION BY list (entity_type);

Further information. What did you do, what did you expect?

Hello,

I have an interesting experience here where I've discovered that a partitioned table is unable to generate the relationships.

When I have the partitioned table in the database, I get the following in the generated models:

image

However, when I remove the partition from the table, I get the following:

image

So, my question comes down to 2 things:

  1. Are relationships supported on Partitioned tables?
  2. Alternatively, is this a bug?

Look forward to your response.

magicMustard avatar Apr 25 '22 07:04 magicMustard

Personally, I haven't used partitions with SQLBoiler so this is not a situation that I have faced.

I could be wrong, but reading through the code, I also don't remember seeing any code specifically about handling partitions, so maybe it had never been supported.

stephenafamo avatar Apr 25 '22 10:04 stephenafamo

Is there any chance this could be implemented if that's the case?

magicMustard avatar Apr 25 '22 11:04 magicMustard

Hey @stephenafamo is there any chance this could be looked into?

magicMustard avatar Jun 09 '22 12:06 magicMustard

Still haven't had time to look into a lot of things, and since partitions are not something I use, I don't see myself looking into this for a while.

I have added the help wanted label in case anyone can help.

If you can get to the root of the issue, or a full implementation, I'll be happy to merge a PR

stephenafamo avatar Jun 09 '22 12:06 stephenafamo

No worries, I understand. If I get a chance of the W/end I'll see if I can see what's happening

magicMustard avatar Jun 09 '22 22:06 magicMustard