{"id":21820578,"url":"https://github.com/sue445/mysql2-nested_hash_bind","last_synced_at":"2025-10-08T03:30:30.417Z","repository":{"id":44097615,"uuid":"505022512","full_name":"sue445/mysql2-nested_hash_bind","owner":"sue445","description":"mysql2 and mysql2-cs-bind extension to bind response to nested Hash","archived":false,"fork":false,"pushed_at":"2025-09-09T14:30:23.000Z","size":111,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-09T17:35:49.418Z","etag":null,"topics":["gem","mysql2"],"latest_commit_sha":null,"homepage":"https://sue445.github.io/mysql2-nested_hash_bind/","language":"Ruby","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/sue445.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-06-19T05:43:29.000Z","updated_at":"2025-09-09T14:30:26.000Z","dependencies_parsed_at":"2023-12-11T13:48:39.448Z","dependency_job_id":"366ee849-480c-43f9-a1d8-aa76eedf27b4","html_url":"https://github.com/sue445/mysql2-nested_hash_bind","commit_stats":{"total_commits":93,"total_committers":3,"mean_commits":31.0,"dds":"0.10752688172043012","last_synced_commit":"2a926d0ad2def8d27a50e61d2587748a065fba5a"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sue445/mysql2-nested_hash_bind","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sue445%2Fmysql2-nested_hash_bind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sue445%2Fmysql2-nested_hash_bind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sue445%2Fmysql2-nested_hash_bind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sue445%2Fmysql2-nested_hash_bind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sue445","download_url":"https://codeload.github.com/sue445/mysql2-nested_hash_bind/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sue445%2Fmysql2-nested_hash_bind/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278866936,"owners_count":26059671,"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-07T02:00:06.786Z","response_time":59,"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":["gem","mysql2"],"created_at":"2024-11-27T16:37:46.897Z","updated_at":"2025-10-08T03:30:30.052Z","avatar_url":"https://github.com/sue445.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mysql2-nested_hash_bind\n[mysql2](https://github.com/brianmario/mysql2) and [mysql2-cs-bind](https://github.com/tagomoris/mysql2-cs-bind) extension to bind response to nested `Hash`.\n\nThis is inspired by https://github.com/jmoiron/sqlx\n\n[![Gem Version](https://badge.fury.io/rb/mysql2-nested_hash_bind.svg)](https://badge.fury.io/rb/mysql2-nested_hash_bind)\n[![test](https://github.com/sue445/mysql2-nested_hash_bind/actions/workflows/test.yml/badge.svg)](https://github.com/sue445/mysql2-nested_hash_bind/actions/workflows/test.yml)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'mysql2-nested_hash_bind'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install mysql2-nested_hash_bind\n\n## Usage\nWrite `require \"mysql2-nested_hash_bind\"` and `using Mysql2::NestedHashBind::QueryExtension` in your code\n\n## Example\n```ruby\nrequire \"mysql2-nested_hash_bind\"\n\nusing Mysql2::NestedHashBind::QueryExtension\n\ndb = Mysql2::Client.new(\n  host: ENV.fetch(\"MYSQL_HOST\", \"127.0.0.1\"),\n  port: ENV.fetch(\"MYSQL_PORT\", \"3306\"),\n  username: ENV.fetch(\"MYSQL_USERNAME\"),\n  database: ENV.fetch(\"MYSQL_DATABASE\"),\n  password: ENV.fetch(\"MYSQL_PASSWORD\", \"\"),\n  charset: \"utf8mb4\",\n  database_timezone: :local,\n  cast_booleans: true,\n  symbolize_keys: true,\n  reconnect: true,\n)\n\nrows = db.query(\u003c\u003c~SQL)\n  SELECT\n    `posts`.`id`,\n    `posts`.`user_id`,\n    `posts`.`body`,\n    `users`.`account_name` AS `users.account_name`,\n    `users`.`authority` AS `users.authority`,\n    `users`.`del_flg` AS `users.del_flg`\n  FROM `posts`\n  INNER JOIN `users` ON `posts`.`user_id` = `users`.`id`\nSQL\n\nrows.first\n#=\u003e {:id=\u003e1, :user_id=\u003e445, :body=\u003e\"test\", :users=\u003e{:account_name=\u003e\"sue445\", :authority=\u003efalse, :del_flg=\u003efalse}}\n```\n\nIf you do not write `using Mysql2::NestedHashBind::QueryExtension`, it will look like this. (This is the original behavior of `Mysql2::Client#query` and `Mysql2::Client#xquery`)\n\n```ruby\nrows.first\n#=\u003e {:id=\u003e1, :user_id=\u003e445, :body=\u003e\"test\", :\"users.account_name\"=\u003e\"sue445\", :\"users.authority\"=\u003efalse, :\"users.del_flg\"=\u003efalse}\n```\n\n## Note\n* If exists columns containing dots, `Mysql2::Client#query` and `Mysql2::Client#xquery` returns `Array\u003cHash\u003e`\n* If no exists columns containing dots, `Mysql2::Client#query` and `Mysql2::Client#xquery` returns [Mysql2::Result](https://www.rubydoc.info/gems/mysql2/Mysql2/Result) (This is the original behavior of `Mysql2::Client#query` and `Mysql2::Client#xquery`)\n\n## Development\nAt first, create test database.\n\ne.g.\n\n```sql\nCREATE DATABASE mysql2_test;\n```\n\n```bash\ncp .env.example .env\nvi .env\n```\n\n## Benchmark\nSee [benchmark/](benchmark/)\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/sue445/mysql2-nested_hash_bind.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsue445%2Fmysql2-nested_hash_bind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsue445%2Fmysql2-nested_hash_bind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsue445%2Fmysql2-nested_hash_bind/lists"}