{"action":"created","comment":{"url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/comments/42774610","id":42774610,"diff_hunk":"@@ -0,0 +1,163 @@\n+-- UTF8 safe and lenght aware. Find a unique identifier with a given prefix\n+-- and/or suffix and withing a schema.\n+CREATE OR REPLACE FUNCTION cartodb.CDB_Unique_Identifier(prefix TEXT, relname TEXT, suffix TEXT, schema TEXT DEFAULT NULL)","path":"scripts-available/CDB_Helper.sql","position":3,"original_position":3,"commit_id":"d14436da6c1433ec6c3917b7d10716134e95077c","original_commit_id":"d14436da6c1433ec6c3917b7d10716134e95077c","user":{"login":"rafatower","id":1914276,"avatar_url":"https://avatars.githubusercontent.com/u/1914276?v=3","gravatar_id":"","url":"https://api.github.com/users/rafatower","html_url":"https://github.com/rafatower","followers_url":"https://api.github.com/users/rafatower/followers","following_url":"https://api.github.com/users/rafatower/following{/other_user}","gists_url":"https://api.github.com/users/rafatower/gists{/gist_id}","starred_url":"https://api.github.com/users/rafatower/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafatower/subscriptions","organizations_url":"https://api.github.com/users/rafatower/orgs","repos_url":"https://api.github.com/users/rafatower/repos","events_url":"https://api.github.com/users/rafatower/events{/privacy}","received_events_url":"https://api.github.com/users/rafatower/received_events","type":"User","site_admin":false},"body":"these should be \"private\" functions, with the `_CDB` prefix","created_at":"2015-10-22T16:55:18Z","updated_at":"2015-10-22T16:55:18Z","html_url":"https://github.com/CartoDB/cartodb-postgresql/pull/173#discussion_r42774610","pull_request_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/173","_links":{"self":{"href":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/comments/42774610"},"html":{"href":"https://github.com/CartoDB/cartodb-postgresql/pull/173#discussion_r42774610"},"pull_request":{"href":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/173"}}},"pull_request":{"url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/173","id":48354230,"html_url":"https://github.com/CartoDB/cartodb-postgresql/pull/173","diff_url":"https://github.com/CartoDB/cartodb-postgresql/pull/173.diff","patch_url":"https://github.com/CartoDB/cartodb-postgresql/pull/173.patch","issue_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/issues/173","number":173,"state":"open","locked":false,"title":"Better unique identifiers","user":{"login":"gfiorav","id":4222826,"avatar_url":"https://avatars.githubusercontent.com/u/4222826?v=3","gravatar_id":"","url":"https://api.github.com/users/gfiorav","html_url":"https://github.com/gfiorav","followers_url":"https://api.github.com/users/gfiorav/followers","following_url":"https://api.github.com/users/gfiorav/following{/other_user}","gists_url":"https://api.github.com/users/gfiorav/gists{/gist_id}","starred_url":"https://api.github.com/users/gfiorav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfiorav/subscriptions","organizations_url":"https://api.github.com/users/gfiorav/orgs","repos_url":"https://api.github.com/users/gfiorav/repos","events_url":"https://api.github.com/users/gfiorav/events{/privacy}","received_events_url":"https://api.github.com/users/gfiorav/received_events","type":"User","site_admin":false},"body":"Fixes #172\r\n\r\nThere are now three new functions: `_CDB_Unique_Identifier`, `_CDB_Unique_Column_Identifier` and `CDB_Octet_Trim` that are used to find unique identifiers taking into account length restrictions (63 octets as in v9.4). They're also UTF8 safe (accounts that different character may have different octet lengths).\r\n\r\nThis deprecates two non-UTF8 non-length aware methods for finding identifiers:\r\n- `_CDB_Unique_Relation_Name`\r\n- `_CDB_Unique_Column_Name`\r\n\r\n\r\nI’m porting the old code that uses these two functions as well. \r\n\r\nStill working on some stuff so this is not ready yet.\r\n\r\nTo do:\r\n- [x] CDB_Unique_Identifier\r\n- [x] CDB_Unique_Column_Identifier\r\n- [x] CDB_Octet_Trim\r\n- [x] Move to CDB_Helper.sql\r\n- [x] Port code using `_CDB_Unique_Relation_Name`\r\n- [x] Port code using `_CDB_Unique_Column_Name `\r\n- [x] Test for CDB_Helper.sql\r\n- [ ] CR\r\n- [ ] Regression tests","created_at":"2015-10-21T16:19:43Z","updated_at":"2015-10-22T16:55:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e32bd60d8cadfaa3ee1780c7a1ad8fc6ae1d1d87","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/173/commits","review_comments_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/173/comments","review_comment_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/issues/173/comments","statuses_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/statuses/d14436da6c1433ec6c3917b7d10716134e95077c","head":{"label":"CartoDB:better-unique-identifiers","ref":"better-unique-identifiers","sha":"d14436da6c1433ec6c3917b7d10716134e95077c","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":13775488,"name":"cartodb-postgresql","full_name":"CartoDB/cartodb-postgresql","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/cartodb-postgresql","description":"PostgreSQL extension for CartoDB","fork":false,"url":"https://api.github.com/repos/CartoDB/cartodb-postgresql","forks_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/forks","keys_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/teams","hooks_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/events","assignees_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/tags","blobs_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/languages","stargazers_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/subscription","commits_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/merges","archive_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/downloads","issues_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/releases{/id}","created_at":"2013-10-22T14:15:48Z","updated_at":"2015-10-22T15:03:03Z","pushed_at":"2015-10-22T15:14:20Z","git_url":"git://github.com/CartoDB/cartodb-postgresql.git","ssh_url":"git@github.com:CartoDB/cartodb-postgresql.git","clone_url":"https://github.com/CartoDB/cartodb-postgresql.git","svn_url":"https://github.com/CartoDB/cartodb-postgresql","homepage":null,"size":2188,"stargazers_count":23,"watchers_count":23,"language":"PLpgSQL","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":37,"forks":18,"open_issues":37,"watchers":23,"default_branch":"master"}},"base":{"label":"CartoDB:master","ref":"master","sha":"cf2587ca542d12f6af9ce92f8004bb21cafe0dff","user":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"repo":{"id":13775488,"name":"cartodb-postgresql","full_name":"CartoDB/cartodb-postgresql","owner":{"login":"CartoDB","id":1799254,"avatar_url":"https://avatars.githubusercontent.com/u/1799254?v=3","gravatar_id":"","url":"https://api.github.com/users/CartoDB","html_url":"https://github.com/CartoDB","followers_url":"https://api.github.com/users/CartoDB/followers","following_url":"https://api.github.com/users/CartoDB/following{/other_user}","gists_url":"https://api.github.com/users/CartoDB/gists{/gist_id}","starred_url":"https://api.github.com/users/CartoDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CartoDB/subscriptions","organizations_url":"https://api.github.com/users/CartoDB/orgs","repos_url":"https://api.github.com/users/CartoDB/repos","events_url":"https://api.github.com/users/CartoDB/events{/privacy}","received_events_url":"https://api.github.com/users/CartoDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CartoDB/cartodb-postgresql","description":"PostgreSQL extension for CartoDB","fork":false,"url":"https://api.github.com/repos/CartoDB/cartodb-postgresql","forks_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/forks","keys_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/teams","hooks_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/hooks","issue_events_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/issues/events{/number}","events_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/events","assignees_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/assignees{/user}","branches_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/branches{/branch}","tags_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/tags","blobs_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/git/refs{/sha}","trees_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/statuses/{sha}","languages_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/languages","stargazers_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/stargazers","contributors_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/contributors","subscribers_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/subscribers","subscription_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/subscription","commits_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/commits{/sha}","git_commits_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/git/commits{/sha}","comments_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/comments{/number}","issue_comment_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/issues/comments{/number}","contents_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/contents/{+path}","compare_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/merges","archive_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/downloads","issues_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/issues{/number}","pulls_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls{/number}","milestones_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/milestones{/number}","notifications_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/labels{/name}","releases_url":"https://api.github.com/repos/CartoDB/cartodb-postgresql/releases{/id}","created_at":"2013-10-22T14:15:48Z","updated_at":"2015-10-22T15:03:03Z","pushed_at":"2015-10-22T15:14:20Z","git_url":"git://github.com/CartoDB/cartodb-postgresql.git","ssh_url":"git@github.com:CartoDB/cartodb-postgresql.git","clone_url":"https://github.com/CartoDB/cartodb-postgresql.git","svn_url":"https://github.com/CartoDB/cartodb-postgresql","homepage":null,"size":2188,"stargazers_count":23,"watchers_count":23,"language":"PLpgSQL","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":37,"forks":18,"open_issues":37,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/173"},"html":{"href":"https://github.com/CartoDB/cartodb-postgresql/pull/173"},"issue":{"href":"https://api.github.com/repos/CartoDB/cartodb-postgresql/issues/173"},"comments":{"href":"https://api.github.com/repos/CartoDB/cartodb-postgresql/issues/173/comments"},"review_comments":{"href":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/173/comments"},"review_comment":{"href":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CartoDB/cartodb-postgresql/pulls/173/commits"},"statuses":{"href":"https://api.github.com/repos/CartoDB/cartodb-postgresql/statuses/d14436da6c1433ec6c3917b7d10716134e95077c"}}}}