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
AUTO_INCREMENT #159
Comments
I'm also familiar with MySQL's There can be something to consider about the implementation plan. |
Hmm |
I tried a number of ways writing it how I might expect it to be writable and with the current sqlparser, (With the NOT NULL always required) Thoughts on |
nb: id INTEGER CONSTRAINT AUTO_INCREMENT NOT NULL Gives us:
|
|
I was trying to implement this using a validation check but it seems this would actually be quite simple by using the existing row/default code. The question just becomes how to decide the value to use. Doing a scan seems it would be rather expensive but once indexes are in (esp considering |
Hmmmmm If this is the case it would probably be most efficient to just use the MSSQL method of just storing and reseeding as needed. If we wanted it to work otherwise it would probably need to check the value each update/insert (specified or not) and update it when that value is bigger &| maybe when values are deleted. |
@panarch do you think it would be better to add a generated parameter on schema or leave it to the store and add a new prefix for sled? |
@KyGost ..
ColumnOptionDef {
name: None,
option: DialectSpecific([
Word(Word { value: "AUTO_INCREMENT", quote_style: None, keyword: AUTO_INCREMENT })
])
.. This above is supported by the latest version of However, GlueSQL is currently using The reason you needed to use |
@panarch
Yup. |
And the design I briefly thought was something like this. Adding optional store trait pub trait AutoIncrement<T: Debug> {
fn generate_id() -> T;
} and implementation idea for
However, without index this above implementation plan can be quite inefficient, so it would be good to do something more on this, like you suggested in the thread. In anyway, the point would be... having store trait api as simple as possible |
It would be quite nice to have an
AUTO_INCREMENT
feature forINTEGER
columns.There's a few approaches to how this could work though:
SQLite automatically acts on
INTEGER PRIMARY KEY
columns, backfilling where values are removed while the keyword specifies that backfill should not occur.https://sqlite.org/autoinc.html
MySQL acts based on the current largest value in the column when the keyword is used.
https://dev.mysql.com/doc/refman/8.0/en/example-auto-increment.html
MSSQL stores a value and uses that. The value can be altered.
https://docs.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property?view=sql-server-ver15
Anyone have any preference?
I'm not sure that I like how SQLite increments by default.
I kinda like the MySQL method; MSSQL sounds a bit messy and I worry for the potential issues of backfilling (SQLite).
The text was updated successfully, but these errors were encountered: