{"id":18044640,"url":"https://github.com/pickfire/diesel-join-not-exist","last_synced_at":"2025-09-21T01:36:10.549Z","repository":{"id":86155371,"uuid":"339798351","full_name":"pickfire/diesel-join-not-exist","owner":"pickfire","description":"Rust diesel join not exist experiment","archived":false,"fork":false,"pushed_at":"2021-03-10T13:25:39.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T03:27:21.126Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pickfire.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-02-17T17:13:06.000Z","updated_at":"2021-03-10T13:25:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"e5d083d6-7d0b-4142-ad43-d823f8215e47","html_url":"https://github.com/pickfire/diesel-join-not-exist","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pickfire/diesel-join-not-exist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pickfire%2Fdiesel-join-not-exist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pickfire%2Fdiesel-join-not-exist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pickfire%2Fdiesel-join-not-exist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pickfire%2Fdiesel-join-not-exist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pickfire","download_url":"https://codeload.github.com/pickfire/diesel-join-not-exist/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pickfire%2Fdiesel-join-not-exist/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276183681,"owners_count":25599223,"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-09-20T02:00:10.207Z","response_time":63,"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":[],"created_at":"2024-10-30T18:10:02.034Z","updated_at":"2025-09-21T01:36:10.524Z","avatar_url":"https://github.com/pickfire.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Diesel join not exist experiment\n================================\n\nPrevious: https://github.com/pickfire/diesel-update-from\nNext: https://github.com/pickfire/diesel-upsert\n\nAfter getting footguns in sequelize and gorm, just want to try out diesel and\nstate of diesel.\n\nI did not found a way to do left join where the other side does not exist, I\nwanted to search a \"has one\" relationship where the parent table does not\nhave anything in the child table. But in gorm, I need to do a hack on `Joins`.\n\nI think I started to get the hang of it. No wall crashing now, I just search\nfor \"left join\" and \"null\", then found `left_join` and `is_null` in the docs.\nTweak the original query, bingo! No surprise.\n\nSeemed too easy now, maybe I need to try something harder next time. Probably\ncomputed property or aggregation since I saw it could be done in diesel.\n\nThe example I tested out here have 3 struct (based on the previous ones).\nsqlite was used for easy testing.\n\n    +---------+     +---------+     +---------+\n    | User    |\u003c-+  | Post    |     | Comment |\n    +---------+  |  +---------+     +---------+\n    | id      |  |  | id      |     | id      |\n    | name    |  |  | title   |     | body    |\n    |         |  |  | body    |\u003c----+ post_id |\n    |         |  |  | user_id +--+--+ user_id |\n    +---------+  |  +---------+  |  +---------+\n                 +---------------+\n\nI want to find all posts that does not have any comments. The query,\n\n```rust\nlet query = posts::table\n    .left_join(comments::table)\n    .select(posts::title)\n    .filter(comments::id.is_null());\n```\n\nWhich results in the SQL query,\n\n```sql\nSELECT\n  `posts`.`title`\n FROM (`posts`\n LEFT OUTER JOIN `comments`\n   ON `comments`.`post_id` = `posts`.`id`)\nWHERE `comments`.`id` IS NULL -- binds: []\n```\n\n## Get started\n\nRust, diesel_cli (with `sqlite` feature) is required.\n\n```\n$ diesel migration run\n$ cargo run --bin init  # populate database\n$ cargo run --bin hello  # multi join query\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpickfire%2Fdiesel-join-not-exist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpickfire%2Fdiesel-join-not-exist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpickfire%2Fdiesel-join-not-exist/lists"}