ormx
ormx copied to clipboard
`Id: Clone` → Use `String` as primary key
Meant to implement #43.
Something I have noticed while doing this is that tables with only one column do not work!
E.g.
#[derive(Debug, ormx::Table)]
#[ormx(table = "users_with_string_id", id = user_id, insertable, deletable)]
struct UserWithStringId {
// `#[ormx(get_one = ..)]` generates `User::get_by_user_id(db, id: String) -> Result<User>` for us
#[ormx(column = "id", default, get_one = get_by_user_id)] // map this field to the column "id"
user_id: String,
}
will raise this error: ERROR: syntax error at or near "WHERE" at character 36
I've narrowed it down to this: UPDATE "users_with_string_id" SET WHERE "id" = $1
See above that between SET and WHERE, there it expects the other columns, but when there are no other columns. This leads to sqlx erroring during marco-expansion, therefore failing to compile.