AUTOINCREMENT does not work?
pengyizeng opened this issue · comments
I create a simple table : user
eg:
let sql = "
CREATE TABLE user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT
);";
created successfully. Then I insert a record without specify the id number:
let sql2 = "INSERT INTO user(name) VALUES ('John'); ";
It occurs an error which tells me I did not specify the "id", how can I insert data without specify the "id"?
This feature is not currently supported.
ref: #159
This feature is not currently supported.
ref: #159
Thanks, then I use UUID as the "id" type, and insert data successfully by "generate_uuid()" . But when I select the data by an id:
eg:
let uuid = "48743284824.....";
let actual = table("user")
.select()
.filter(col("id").eq(uuid))
.project("id, name")
.build()
.expect("build and execute")
.execute(glue)
.await;
went wrong, how to specify the filter when the id type is UUID?
gluesql/test-suite/src/data_type/uuid.rs
Lines 44 to 74 in ecc6fdf
gluesql/core/src/data/value/literal.rs
Line 121 in ecc6fdf
gluesql/core/src/data/value/literal.rs
Lines 620 to 624 in ecc6fdf
Can you provide a little more information?
If I add the test case below, it works fine.
let actual = table("Foo")
.create_table()
.add_column("id UUID")
.add_column("name TEXT")
.execute(glue)
.await;
let expected = Ok(Payload::Create);
assert_eq!(actual, expected, "create table");
let actual = table("Foo")
.insert()
.columns("id, name")
.values(vec![vec![
text("936DA01F9ABD4d9d80C702AF85C822A8"),
text("hi"),
]])
.execute(glue)
.await;
let expected = Ok(Payload::Insert(1));
assert_eq!(actual, expected, "insert");
let actual = table("Foo")
.select()
.filter(col("id").eq(text("936DA01F9ABD4d9d80C702AF85C822A8")))
.project("id, name")
.execute(glue)
.await;
let uuid = Uuid::parse_str("936DA01F9ABD4d9d80C702AF85C822A8")
.unwrap()
.as_u128();
let expected = Ok(select!(
id | name
Uuid | Str;
uuid "hi".to_owned()
));
assert_eq!(actual, expected);
I think I should use parse_uuid() instead of using the u128 string format, thanks a lot!