{"id":28535052,"url":"https://github.com/bitfl0wer/sqlx-pg-uint","last_synced_at":"2026-03-05T02:02:55.264Z","repository":{"id":253573791,"uuid":"843873940","full_name":"bitfl0wer/sqlx-pg-uint","owner":"bitfl0wer","description":"SQLx extension to support working with Rust unsigned integers in PostgreSQL.","archived":false,"fork":false,"pushed_at":"2025-05-02T10:54:03.000Z","size":76,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-19T22:34:23.746Z","etag":null,"topics":["sqlx","sqlx-adapter","sqlx-pg","sqlx-postgres"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/sqlx-pg-uint","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitfl0wer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-17T17:20:23.000Z","updated_at":"2025-06-26T11:06:34.000Z","dependencies_parsed_at":"2025-03-09T11:32:18.860Z","dependency_job_id":null,"html_url":"https://github.com/bitfl0wer/sqlx-pg-uint","commit_stats":null,"previous_names":["bitfl0wer/sqlx-pg-uint"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/bitfl0wer/sqlx-pg-uint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfl0wer%2Fsqlx-pg-uint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfl0wer%2Fsqlx-pg-uint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfl0wer%2Fsqlx-pg-uint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfl0wer%2Fsqlx-pg-uint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitfl0wer","download_url":"https://codeload.github.com/bitfl0wer/sqlx-pg-uint/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfl0wer%2Fsqlx-pg-uint/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278485924,"owners_count":25994939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sqlx","sqlx-adapter","sqlx-pg","sqlx-postgres"],"created_at":"2025-06-09T17:13:49.671Z","updated_at":"2025-10-08T07:06:24.332Z","avatar_url":"https://github.com/bitfl0wer.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sqlx-pg-uint\n\n`SQLx` extension to support working with Rust unsigned integers in PostgreSQL.\n\n---\n\nThis crate provides types with `sqlx::{Encode, Decode, Type}` implemented for them, which allow you\nto work with fixed-size unsigned integers in PostgreSQL.\n\n```rs\nuse sqlx_pg_uint::PgU64;\n\nfn main() {\n    let a_u64_number = 2937854645u64;\n    let pg_u_64 = PgU64::from(a_u64_number);\n    println!(\"PgU64: {}\", pg_u_64);\n    let back_to_u64: u64 = pg_u_64.to_uint();\n    println!(\"Back to u64: {}\", back_to_u64);\n    println!(\n        \"Maths work the same way as you'd expect: {}\",\n        PgU64::from(67) + PgU64::from(2) * PgU64::from(3) / PgU64::from(3)\n    );\n    println!(\n        \"Interact with the underlying BigDecimal type directly: {}\",\n        pg_u_64.as_big_decimal()\n    );\n    println!(\"You can also convert an Option\u003cPgUInt\u003e to a Option\u003cuint\u003e easily.\")\n    let somepguint: Option\u003cPgU32\u003e = Some(PgU32::from(123u32));\n    let someuint: Option\u003cu32\u003e = somepguint.to_option_uint();\n    assert_eq!(someuint, Some(123u32));\n    println!(\"PgUint types can be converted to and from BigDecimals, and are storable in an sqlx::Postgres database.\");\n    println!(\"If you load a PgUint from a database successfully, you can be sure that it's a valid fixed-size unsigned integer.\");\n}\n```\n\nWhen defining a column for a PostgreSQL table, which should store a fixed-size unsigned integer,\nyou should use the `NUMERIC` type.\n\n| Rust Type | PostgreSQL Type  |\n| --------- | ---------------- |\n| `PgU8`    | `NUMERIC(3, 0)`  |\n| `PgU16`   | `NUMERIC(5, 0)`  |\n| `PgU32`   | `NUMERIC(10, 0)` |\n| `PgU64`   | `NUMERIC(20, 0)` |\n| `PgU128`  | `NUMERIC(39, 0)` |\n\nAdditionally, you are advised to use `constraints` to ensure that the value stored in the column is\na valid fixed-size unsigned integer, guaranteed to be in range for the type.\n\n```sql\nCREATE TABLE my_table (\n    -- `id` is an unsigned 64-bit integer in the corresponding Rust struct\n    id numeric(20, 0) not null constraint chk_id_range check (id \u003e= 0 AND id \u003c= 18446744073709551615),\n);\n```\n\n\u003e Constraining columns (or Rust types) to only store valid values is not a recommendation specific to\n\u003e this crate, but a general best practice to avoid faulty states in your application.\n\n## serde\n\nThis crate also provides serde de-/serialization, if the `serde` feature is enabled.\n\nWith the `serde` feature enabled, you can use the `PgUint` types in structs that you want to serialize and deserialize.\n\nTypes are serialized as their respective unsigned integer values, and deserialized using the underlying `Deserialize` trait implemented for `BigDecimal`.\n\n## MSRV\n\n1.81.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfl0wer%2Fsqlx-pg-uint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfl0wer%2Fsqlx-pg-uint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfl0wer%2Fsqlx-pg-uint/lists"}