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

Feature: support tables without a primary key #1661

Closed
Diggsey opened this Issue Apr 25, 2018 · 7 comments

Comments

Projects
None yet
4 participants
@Diggsey
Contributor

Diggsey commented Apr 25, 2018

Pretty self explanatory - there's not really a reason to prevent inserting into a table without a primary key. Not supporting operations requiring Identifiable is fine.

@sgrif

This comment has been minimized.

Member

sgrif commented Apr 25, 2018

This isn't possible until Diesel 2.0. We may eventually try to generalize "data source" as a supertrait of Table, which has no primary key (e.g. views), but tables should always have some form of primary key.

@sgrif sgrif closed this Apr 25, 2018

@Diggsey

This comment has been minimized.

Contributor

Diggsey commented Apr 25, 2018

Is that because it would require breaking changes? AFAICT, the only part of diesel currently using knowledge of the primary key is the find() method. Everything else works equally well without a primary key.

@weiznich

This comment has been minimized.

Contributor

weiznich commented Apr 25, 2018

It will require a breaking change because we need do separate Table in such a way that there is a supertrait of Table that contains the AllColumns associated type and the all_columns function. The Table trait would than contain only the PrimaryKey associated type and the primary_key function. It is a breaking change because this would break all code that currently implements Table.

@sgrif Maybe we should introduce a diesel 2.0 tag to have a list of things we may want to fix in 2.0?

@Diggsey

This comment has been minimized.

Contributor

Diggsey commented Apr 25, 2018

Not calling it a Table seems confusing - whether or not something has a primary key is incidental to whether it's a table.

I currently have a table which implements a "set" data structure - the "value" is not the primary key because for reasons relating to locking, it is preferable to allow transient duplicate items than to enforce uniqueness (which could cause "insert" operations to have to wait on "remove" transactions, which are slow).

@sgrif

This comment has been minimized.

Member

sgrif commented Apr 25, 2018

@Diggsey You can just tell Diesel some random column is the primary key

@KeenS

This comment has been minimized.

Contributor

KeenS commented Oct 31, 2018

Is this planned to be developed for diesel 2.0? (And is diesel 2.0 is planned?)

I want to use partitioned tables, which doesn't support primary key.

@KeenS

This comment has been minimized.

Contributor

KeenS commented Nov 5, 2018

I found diesel_cli supports table filtering.
https://github.com/diesel-rs/diesel/blob/master/diesel_cli/tests/print_schema/print_schema_except_tables/diesel.toml
I'm going to use it until diesel 2.0 get released

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