{"action":"created","comment":{"url":"https://api.github.com/repos/hanami/hanami.github.io/pulls/comments/169780824","pull_request_review_id":98364129,"id":169780824,"diff_hunk":"@@ -218,6 +217,72 @@ operator = OperatorRepository.new.create(name: \"Jane\")\n   # => #<Operator:0x007f8e43cbcea0 @attributes={:id=>1, :name=>\"Jane\"}>\n ```\n \n+There's a few caveats tho (as always with legacy databases):\n+\n+Note that all attributes need to be mapped or you will get an error when booting up the application that will look like this:\n+\n+```ruby\n+class OperatorRepository < Hanami::Repository\n+  self.relation = :t_operator\n+  \n+  mapping do\n+    attribute :id, from: :operator_id\n+  end\n+end\n+\n+  # => Hanami::Model::Error: key not found: :s_name\n+```\n+That happens because we infer the schema for the table and mapping only really changes the `Hanami::Entity` and commands that operate over it (like `create` and `update`).\n+\n+A query on the other hand will still need to use the original attribute name:\n+\n+```ruby\n+class OperatorRepository < Hanami::Repository\n+  self.relation = :t_operator\n+  \n+  mapping do\n+    attribute :id,   from: :operator_id\n+    attribute :name, from: :s_name\n+  end\n+  \n+  def by_name(name)\n+    t_operator.where(s_name: name)\n+  end\n+end\n+```\n+\n+If you want to use the more semantic names (or with just a subset of attributes) you'll need to define a schema and a mapping:\n+\n+```ruby\n+class OperatorRepository < Hanami::Repository\n+  self.relation = :t_operator\n+  \n+  schema do\n+    attribute :operator_id, Hanami::Model::Sql::Types::Int.meta(primary_key: true, alias: :id)","path":"source/guides/1.1/repositories/overview.md","position":null,"original_position":53,"commit_id":"5da296e21d945b1f7d9f3d99a675994d19031e92","original_commit_id":"8aaf703321f0272bc465b9456c5378d59f41968a","user":{"login":"mereghost","id":10281,"avatar_url":"https://avatars1.githubusercontent.com/u/10281?v=4","gravatar_id":"","url":"https://api.github.com/users/mereghost","html_url":"https://github.com/mereghost","followers_url":"https://api.github.com/users/mereghost/followers","following_url":"https://api.github.com/users/mereghost/following{/other_user}","gists_url":"https://api.github.com/users/mereghost/gists{/gist_id}","starred_url":"https://api.github.com/users/mereghost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mereghost/subscriptions","organizations_url":"https://api.github.com/users/mereghost/orgs","repos_url":"https://api.github.com/users/mereghost/repos","events_url":"https://api.github.com/users/mereghost/events{/privacy}","received_events_url":"https://api.github.com/users/mereghost/received_events","type":"User","site_admin":false},"body":"While we probably could use `Dry::Types` not sure if it wouldn't lead to confusion as the end user might think something along the likes of \"oh I need yet another lib to do this\". ","created_at":"2018-02-21T21:19:55Z","updated_at":"2018-02-21T21:19:55Z","html_url":"https://github.com/hanami/hanami.github.io/pull/431#discussion_r169780824","pull_request_url":"https://api.github.com/repos/hanami/hanami.github.io/pulls/431","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/hanami/hanami.github.io/pulls/comments/169780824"},"html":{"href":"https://github.com/hanami/hanami.github.io/pull/431#discussion_r169780824"},"pull_request":{"href":"https://api.github.com/repos/hanami/hanami.github.io/pulls/431"}},"in_reply_to_id":164763782},"pull_request":{"url":"https://api.github.com/repos/hanami/hanami.github.io/pulls/431","id":165987794,"html_url":"https://github.com/hanami/hanami.github.io/pull/431","diff_url":"https://github.com/hanami/hanami.github.io/pull/431.diff","patch_url":"https://github.com/hanami/hanami.github.io/pull/431.patch","issue_url":"https://api.github.com/repos/hanami/hanami.github.io/issues/431","number":431,"state":"open","locked":false,"title":"Expands the info about legacy database support","user":{"login":"mereghost","id":10281,"avatar_url":"https://avatars1.githubusercontent.com/u/10281?v=4","gravatar_id":"","url":"https://api.github.com/users/mereghost","html_url":"https://github.com/mereghost","followers_url":"https://api.github.com/users/mereghost/followers","following_url":"https://api.github.com/users/mereghost/following{/other_user}","gists_url":"https://api.github.com/users/mereghost/gists{/gist_id}","starred_url":"https://api.github.com/users/mereghost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mereghost/subscriptions","organizations_url":"https://api.github.com/users/mereghost/orgs","repos_url":"https://api.github.com/users/mereghost/repos","events_url":"https://api.github.com/users/mereghost/events{/privacy}","received_events_url":"https://api.github.com/users/mereghost/received_events","type":"User","site_admin":false},"body":"Adding some info on how to deal with legacy databases, the caveats of mapping and working with just a subset of the schema.\r\n\r\nI'm open to suggestions. ","created_at":"2018-01-30T13:58:04Z","updated_at":"2018-02-21T21:19:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bc5815d2ff71d0412ae9075f479d0d09ae2ec1a1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hanami/hanami.github.io/pulls/431/commits","review_comments_url":"https://api.github.com/repos/hanami/hanami.github.io/pulls/431/comments","review_comment_url":"https://api.github.com/repos/hanami/hanami.github.io/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hanami/hanami.github.io/issues/431/comments","statuses_url":"https://api.github.com/repos/hanami/hanami.github.io/statuses/5da296e21d945b1f7d9f3d99a675994d19031e92","head":{"label":"hanami:legacy-databases","ref":"legacy-databases","sha":"5da296e21d945b1f7d9f3d99a675994d19031e92","user":{"login":"hanami","id":3210273,"avatar_url":"https://avatars1.githubusercontent.com/u/3210273?v=4","gravatar_id":"","url":"https://api.github.com/users/hanami","html_url":"https://github.com/hanami","followers_url":"https://api.github.com/users/hanami/followers","following_url":"https://api.github.com/users/hanami/following{/other_user}","gists_url":"https://api.github.com/users/hanami/gists{/gist_id}","starred_url":"https://api.github.com/users/hanami/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanami/subscriptions","organizations_url":"https://api.github.com/users/hanami/orgs","repos_url":"https://api.github.com/users/hanami/repos","events_url":"https://api.github.com/users/hanami/events{/privacy}","received_events_url":"https://api.github.com/users/hanami/received_events","type":"Organization","site_admin":false},"repo":{"id":15563290,"name":"hanami.github.io","full_name":"hanami/hanami.github.io","owner":{"login":"hanami","id":3210273,"avatar_url":"https://avatars1.githubusercontent.com/u/3210273?v=4","gravatar_id":"","url":"https://api.github.com/users/hanami","html_url":"https://github.com/hanami","followers_url":"https://api.github.com/users/hanami/followers","following_url":"https://api.github.com/users/hanami/following{/other_user}","gists_url":"https://api.github.com/users/hanami/gists{/gist_id}","starred_url":"https://api.github.com/users/hanami/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanami/subscriptions","organizations_url":"https://api.github.com/users/hanami/orgs","repos_url":"https://api.github.com/users/hanami/repos","events_url":"https://api.github.com/users/hanami/events{/privacy}","received_events_url":"https://api.github.com/users/hanami/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hanami/hanami.github.io","description":"Hanami website","fork":false,"url":"https://api.github.com/repos/hanami/hanami.github.io","forks_url":"https://api.github.com/repos/hanami/hanami.github.io/forks","keys_url":"https://api.github.com/repos/hanami/hanami.github.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hanami/hanami.github.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hanami/hanami.github.io/teams","hooks_url":"https://api.github.com/repos/hanami/hanami.github.io/hooks","issue_events_url":"https://api.github.com/repos/hanami/hanami.github.io/issues/events{/number}","events_url":"https://api.github.com/repos/hanami/hanami.github.io/events","assignees_url":"https://api.github.com/repos/hanami/hanami.github.io/assignees{/user}","branches_url":"https://api.github.com/repos/hanami/hanami.github.io/branches{/branch}","tags_url":"https://api.github.com/repos/hanami/hanami.github.io/tags","blobs_url":"https://api.github.com/repos/hanami/hanami.github.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hanami/hanami.github.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hanami/hanami.github.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/hanami/hanami.github.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hanami/hanami.github.io/statuses/{sha}","languages_url":"https://api.github.com/repos/hanami/hanami.github.io/languages","stargazers_url":"https://api.github.com/repos/hanami/hanami.github.io/stargazers","contributors_url":"https://api.github.com/repos/hanami/hanami.github.io/contributors","subscribers_url":"https://api.github.com/repos/hanami/hanami.github.io/subscribers","subscription_url":"https://api.github.com/repos/hanami/hanami.github.io/subscription","commits_url":"https://api.github.com/repos/hanami/hanami.github.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/hanami/hanami.github.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/hanami/hanami.github.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/hanami/hanami.github.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/hanami/hanami.github.io/contents/{+path}","compare_url":"https://api.github.com/repos/hanami/hanami.github.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hanami/hanami.github.io/merges","archive_url":"https://api.github.com/repos/hanami/hanami.github.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hanami/hanami.github.io/downloads","issues_url":"https://api.github.com/repos/hanami/hanami.github.io/issues{/number}","pulls_url":"https://api.github.com/repos/hanami/hanami.github.io/pulls{/number}","milestones_url":"https://api.github.com/repos/hanami/hanami.github.io/milestones{/number}","notifications_url":"https://api.github.com/repos/hanami/hanami.github.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hanami/hanami.github.io/labels{/name}","releases_url":"https://api.github.com/repos/hanami/hanami.github.io/releases{/id}","deployments_url":"https://api.github.com/repos/hanami/hanami.github.io/deployments","created_at":"2014-01-01T11:16:40Z","updated_at":"2018-02-17T05:39:08Z","pushed_at":"2018-02-21T20:58:59Z","git_url":"git://github.com/hanami/hanami.github.io.git","ssh_url":"git@github.com:hanami/hanami.github.io.git","clone_url":"https://github.com/hanami/hanami.github.io.git","svn_url":"https://github.com/hanami/hanami.github.io","homepage":"http://hanamirb.org","size":47517,"stargazers_count":89,"watchers_count":89,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":182,"mirror_url":null,"archived":false,"open_issues_count":20,"license":null,"forks":182,"open_issues":20,"watchers":89,"default_branch":"build"}},"base":{"label":"hanami:build","ref":"build","sha":"b65a92b145d437dee3f09895f6681d980cad3b9a","user":{"login":"hanami","id":3210273,"avatar_url":"https://avatars1.githubusercontent.com/u/3210273?v=4","gravatar_id":"","url":"https://api.github.com/users/hanami","html_url":"https://github.com/hanami","followers_url":"https://api.github.com/users/hanami/followers","following_url":"https://api.github.com/users/hanami/following{/other_user}","gists_url":"https://api.github.com/users/hanami/gists{/gist_id}","starred_url":"https://api.github.com/users/hanami/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanami/subscriptions","organizations_url":"https://api.github.com/users/hanami/orgs","repos_url":"https://api.github.com/users/hanami/repos","events_url":"https://api.github.com/users/hanami/events{/privacy}","received_events_url":"https://api.github.com/users/hanami/received_events","type":"Organization","site_admin":false},"repo":{"id":15563290,"name":"hanami.github.io","full_name":"hanami/hanami.github.io","owner":{"login":"hanami","id":3210273,"avatar_url":"https://avatars1.githubusercontent.com/u/3210273?v=4","gravatar_id":"","url":"https://api.github.com/users/hanami","html_url":"https://github.com/hanami","followers_url":"https://api.github.com/users/hanami/followers","following_url":"https://api.github.com/users/hanami/following{/other_user}","gists_url":"https://api.github.com/users/hanami/gists{/gist_id}","starred_url":"https://api.github.com/users/hanami/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanami/subscriptions","organizations_url":"https://api.github.com/users/hanami/orgs","repos_url":"https://api.github.com/users/hanami/repos","events_url":"https://api.github.com/users/hanami/events{/privacy}","received_events_url":"https://api.github.com/users/hanami/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/hanami/hanami.github.io","description":"Hanami website","fork":false,"url":"https://api.github.com/repos/hanami/hanami.github.io","forks_url":"https://api.github.com/repos/hanami/hanami.github.io/forks","keys_url":"https://api.github.com/repos/hanami/hanami.github.io/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hanami/hanami.github.io/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hanami/hanami.github.io/teams","hooks_url":"https://api.github.com/repos/hanami/hanami.github.io/hooks","issue_events_url":"https://api.github.com/repos/hanami/hanami.github.io/issues/events{/number}","events_url":"https://api.github.com/repos/hanami/hanami.github.io/events","assignees_url":"https://api.github.com/repos/hanami/hanami.github.io/assignees{/user}","branches_url":"https://api.github.com/repos/hanami/hanami.github.io/branches{/branch}","tags_url":"https://api.github.com/repos/hanami/hanami.github.io/tags","blobs_url":"https://api.github.com/repos/hanami/hanami.github.io/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hanami/hanami.github.io/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hanami/hanami.github.io/git/refs{/sha}","trees_url":"https://api.github.com/repos/hanami/hanami.github.io/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hanami/hanami.github.io/statuses/{sha}","languages_url":"https://api.github.com/repos/hanami/hanami.github.io/languages","stargazers_url":"https://api.github.com/repos/hanami/hanami.github.io/stargazers","contributors_url":"https://api.github.com/repos/hanami/hanami.github.io/contributors","subscribers_url":"https://api.github.com/repos/hanami/hanami.github.io/subscribers","subscription_url":"https://api.github.com/repos/hanami/hanami.github.io/subscription","commits_url":"https://api.github.com/repos/hanami/hanami.github.io/commits{/sha}","git_commits_url":"https://api.github.com/repos/hanami/hanami.github.io/git/commits{/sha}","comments_url":"https://api.github.com/repos/hanami/hanami.github.io/comments{/number}","issue_comment_url":"https://api.github.com/repos/hanami/hanami.github.io/issues/comments{/number}","contents_url":"https://api.github.com/repos/hanami/hanami.github.io/contents/{+path}","compare_url":"https://api.github.com/repos/hanami/hanami.github.io/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hanami/hanami.github.io/merges","archive_url":"https://api.github.com/repos/hanami/hanami.github.io/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hanami/hanami.github.io/downloads","issues_url":"https://api.github.com/repos/hanami/hanami.github.io/issues{/number}","pulls_url":"https://api.github.com/repos/hanami/hanami.github.io/pulls{/number}","milestones_url":"https://api.github.com/repos/hanami/hanami.github.io/milestones{/number}","notifications_url":"https://api.github.com/repos/hanami/hanami.github.io/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hanami/hanami.github.io/labels{/name}","releases_url":"https://api.github.com/repos/hanami/hanami.github.io/releases{/id}","deployments_url":"https://api.github.com/repos/hanami/hanami.github.io/deployments","created_at":"2014-01-01T11:16:40Z","updated_at":"2018-02-17T05:39:08Z","pushed_at":"2018-02-21T20:58:59Z","git_url":"git://github.com/hanami/hanami.github.io.git","ssh_url":"git@github.com:hanami/hanami.github.io.git","clone_url":"https://github.com/hanami/hanami.github.io.git","svn_url":"https://github.com/hanami/hanami.github.io","homepage":"http://hanamirb.org","size":47517,"stargazers_count":89,"watchers_count":89,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":182,"mirror_url":null,"archived":false,"open_issues_count":20,"license":null,"forks":182,"open_issues":20,"watchers":89,"default_branch":"build"}},"_links":{"self":{"href":"https://api.github.com/repos/hanami/hanami.github.io/pulls/431"},"html":{"href":"https://github.com/hanami/hanami.github.io/pull/431"},"issue":{"href":"https://api.github.com/repos/hanami/hanami.github.io/issues/431"},"comments":{"href":"https://api.github.com/repos/hanami/hanami.github.io/issues/431/comments"},"review_comments":{"href":"https://api.github.com/repos/hanami/hanami.github.io/pulls/431/comments"},"review_comment":{"href":"https://api.github.com/repos/hanami/hanami.github.io/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hanami/hanami.github.io/pulls/431/commits"},"statuses":{"href":"https://api.github.com/repos/hanami/hanami.github.io/statuses/5da296e21d945b1f7d9f3d99a675994d19031e92"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"mereghost"}}