{"id":17596140,"url":"https://github.com/fyko/scyllax","last_synced_at":"2026-03-11T04:31:14.471Z","repository":{"id":191309716,"uuid":"684385808","full_name":"Fyko/scyllax","owner":"Fyko","description":"A coalescing query system for Scylla ","archived":false,"fork":false,"pushed_at":"2024-09-10T16:14:13.000Z","size":336,"stargazers_count":9,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-20T21:26:55.724Z","etag":null,"topics":["coalescing","orm","rust","scylla","tokio"],"latest_commit_sha":null,"homepage":"https://fyko.github.io/scyllax","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fyko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","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":"2023-08-29T03:03:51.000Z","updated_at":"2025-09-11T19:34:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"7223bd9b-a8e2-42ea-87f9-0807605f1ff2","html_url":"https://github.com/Fyko/scyllax","commit_stats":null,"previous_names":["trufflehq/scyllax","fyko/scyllax"],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/Fyko/scyllax","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fyko%2Fscyllax","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fyko%2Fscyllax/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fyko%2Fscyllax/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fyko%2Fscyllax/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fyko","download_url":"https://codeload.github.com/Fyko/scyllax/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fyko%2Fscyllax/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30212103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["coalescing","orm","rust","scylla","tokio"],"created_at":"2024-10-22T08:08:06.646Z","updated_at":"2026-03-11T04:31:14.370Z","avatar_url":"https://github.com/Fyko.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scyllax (sɪl-æks)\nA SQLx and Discord inspired query system for Scylla.\n\n[![discord](https://img.shields.io/discord/1041931589631881257?color=5865F2\u0026logo=discord\u0026logoColor=white)](https://discord.gg/HnyYTnQzJW)\n[![codecov](https://codecov.io/gh/fyko/scyllax/graph/badge.svg?token=OGH77YR0TA)](https://codecov.io/gh/fyko/scyllax)\n[![CI](https://github.com/fyko/scyllax/actions/workflows/ci.yml/badge.svg)](https://github.com/fyko/scyllax/actions/workflows/ci.yml)\n\n## Example\n### 1. Model definition\nBefore you can write any queries, you have to define a model.\n```rust,ignore\n#[entity]\npub struct PersonEntity {\n    #[entity(primary_key)]\n    pub id: uuid::Uuid,\n    pub email: String,\n    pub created_at: i64,\n}\n```\n\n### 2. Read queries\nWith the [`read_query`] attribute, it's easy to define select queries.\n```rust,ignore\n#[read_query(\n    query = \"select * from person where id = :id limit 1\",\n    return_type = \"PersonEntity\"\n)]\npub struct GetPersonById {\n    pub id: Uuid,\n}\n```\n\n### 3. Upsert queries\nWith the [`upsert_query`] attribute, it's easy to define upsert queries.\n```rust,ignore\n#[entity]\n#[upsert_query(table = \"person\", name = UpsertPerson)]\npub struct PersonEntity {\n    #[entity(primary_key)]\n    pub id: uuid::Uuid,\n    pub email: String,\n    pub created_at: i64,\n}\n```\n\n### 4. Query Collections\nScylla required queries be prepared before they can be executed. To prepare (and check) all queries at startup, create a query collection and pass it into an Executor.\n```rust,ignore\ncreate_query_collection!(\n    PersonQueries,\n    [\n        GetPersonById,\n        GetPersonByEmail\n    ],\n    [\n        DeletePersonById,\n        UpsertPerson\n    ]\n);\n\nlet executor = Executor::\u003cPersonQueries\u003e::new(Arc::new(session)).await;\n\nlet user = executor.execute_read(GetPersonByEmail {\n    email: \"user@fyko.net\".to_string(),\n}).await?;\n\nprintln!(\"{user:#?}\");\n```\n\n## Features\n- [x] Read Queries\n- [x] Write Queries (https://github.com/fyko/scyllax/pull/1)\n- [x] Request Coalescing\n- [x] Compile-time Select Query Validation\n  - ensure the where constraints exist on the struct\n  - ensure the where constraints are the same type as the struct\n- [ ] Runtime Query Validation (structure matches schema)\n\n### Todo\n- [x] Eject `anyhow`, more refined errors\n\n## Usage\nSee the [example](example) for more details.\n\n## References\n1. https://www.reddit.com/r/rust/comments/11ki2n7/a_look_at_how_discord_uses_rust_for_their_data/jb8dmrx/\n\n```rs\n#[read_request(\n    query = \"select * from foo where id = ? limit 1\",\n    entity_type = \"Foo\"\n)]\nstruct GetFooById {\n    #[shard_key]\n    id: i64\n}\n```\n\n```rs\nhandle.execute_read(GetFooById { ... }).await\n```\n\n**Messages from Jake**\n\n\u003e the answer though is that unlike the scylla rust wrapper, we don't need the fields to be in the right order for our stuff to work.\n\u003e we do 2 clever things:\n\n\u003e 1) `SELECT *` is actually a lie. Never use `SELECT *` in a prepared statement, **ever**. CQL suffers from a protocol level bug that can lead to data corruption on schema change when doing a `SELECT *` due to a schema de-sync condition that is possible between the client \u0026 server. So instead, what we do is, we look at the entity type struct, and we transform `SELECT *` into `SELECT col_a, col_b, col_c`. That means if a column present in the schema, but not in the struct we're going to de-serialize to, we don't actually query it. The gist of the bug is that, when a new column is added to a table, the database may start returning data for that column, without the client being aware of that. In the pathological case, this can cause a mis-aligned deserialziation of the data. https://docs.datastax.com/en/developer/java-driver/3.0/manual/statements/prepared/#avoid-preparing-select-queries - although this does look like it's finally fixed in native protocol v5, I'm unsure if scylla is using that yet.\n\n\u003e 2) For binding of the query parameters as well, we essentially parse the SQL statement and figure out all of the bind positions, and then generate code that will bind the fields in the proper order (since on the wire level, they need to be specified in the order that they're defined in the query.) We do this at compile time in a proc macro to generate the code that does the serialization of the query, so we incur no runtime overhead of re-ordering things.\n\n\u003e At startup we prepare everything and also type check the structs in code against what's in the db\nRegistering everything manually is fine\nYou can make it fail at compile time\nIf you try to use an unregistered query\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffyko%2Fscyllax","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffyko%2Fscyllax","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffyko%2Fscyllax/lists"}