Skip to content

Conversation

@timephy
Copy link

@timephy timephy commented Oct 8, 2025

Meant to implement #43.

@timephy
Copy link
Author

timephy commented Oct 8, 2025

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant