-
Notifications
You must be signed in to change notification settings - Fork 109
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
Move 'constraints' markers to primitive and fix incompatibility with deploy #561
Conversation
//! | ||
//! A column that is made up of values generated by the database using a sequence. | ||
//! | ||
//! Differs from `PRIMARY_KEY` in that its values are managed by the database and usually cannot be modified. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: Currently IDENTITY
implies UNIQUE
but that is wrong: https://en.wikipedia.org/wiki/Identity_column.
However, to change this need we review how others are using this.
@@ -52,6 +52,15 @@ pub struct Point { | |||
y: i64, | |||
} | |||
|
|||
// Test we can compile multiple constraints | |||
#[spacetimedb(table)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is added to check it compiles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. You might have to change an integration smoke test which reads specific log lines because another table will add a log line and through the numbers off by one.
//! Additionally, is possible to add markers to columns as: | ||
//! | ||
//! - AUTO_INC: Auto-generate a sequence | ||
//! - INDEXED: Auto-generate a non-unique index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: AUTO_INC
right now is semantically ambiguous. it clashes with the purpose of IDENTITY
(and is possible to have many of it) which is the recommended one when asked for auto-generated numbers.
I think we should use instead SEQUENCE
and deprecate the use of this tag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code change itself looks good to me. I want to make sure we discuss in chat how we are going agree on the semantics you bring up here, before approving. Thanks for the pointers to documentation about it, Mario.
@@ -52,6 +52,15 @@ pub struct Point { | |||
y: i64, | |||
} | |||
|
|||
// Test we can compile multiple constraints | |||
#[spacetimedb(table)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. You might have to change an integration smoke test which reads specific log lines because another table will add a log line and through the numbers off by one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! <3 the docs
|
||
/// The assigned constraint for a `Table` | ||
#[allow(non_camel_case_types)] | ||
#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO these are all confused. We should just have attributes which are separate from constraints:
IMO these shouldn't even be on the same axis.
We have the following column attributes:
- auto_inc
We should have the following table attributes:
- primary_key e.g.
(col_a, col_b)
- indexed e.g.
(col_a, col_b)
We should have the following table constraints:
- unique e.g.
(col_a, col_b)
These are all mutually exclusive and should not be combined into a single "kind"
Also constraints != attributes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be addressed in a separate PR, this one is to solve the immediate issue with deploy.
…umns defined for table'
fd57740
to
d65c99d
Compare
Description of Changes
Refactor the definition of
constraints
into theprimitives
crate, removing duplications of logic and fix bug whengives error
Multiple primary columns defined for table
, which shows up in the deployment ofspacetimedb.com
API and ABI breaking changes
This changes the
bits
stored in thest_constraints
system table.Expected complexity level and risk
1