{"action":"created","comment":{"url":"https://api.github.com/repos/dcreager/avro/pulls/comments/28702993","id":28702993,"diff_hunk":"@@ -556,6 +560,77 @@ avro_schema_record_field_append(const avro_schema_t record_schema,\n \treturn 0;\n }\n \n+\n+static int\n+avro_schema_record_field_append_with_default_json(const avro_schema_t record_schema,\n+                                                  const char *field_name,\n+                                                  const avro_schema_t field_schema,\n+                                                  const json_t *field_default)\n+{\n+\tcheck_param(EINVAL, is_avro_schema(record_schema), \"record schema\");\n+\tcheck_param(EINVAL, is_avro_record(record_schema), \"record schema\");\n+\tcheck_param(EINVAL, field_name, \"field name\");\n+\tcheck_param(EINVAL, is_avro_schema(field_schema), \"field schema\");\n+        check_param(EINVAL, field_default, \"field_default\");\n+\n+\tif (!is_avro_id(field_name)) {\n+\t\tavro_set_error(\"Invalid Avro identifier\");\n+\t\treturn EINVAL;\n+\t}\n+\n+\tif (record_schema == field_schema) {\n+\t\tavro_set_error(\"Cannot create a circular schema\");\n+\t\treturn EINVAL;\n+\t}\n+\n+\tstruct avro_record_schema_t *record = avro_schema_to_record(record_schema);\n+\tstruct avro_record_field_t *new_field = (struct avro_record_field_t *) avro_new(struct avro_record_field_t);\n+\tif (!new_field) {\n+\t\tavro_set_error(\"Cannot allocate new record field\");\n+\t\treturn ENOMEM;\n+\t}\n+\tnew_field->index = record->fields->num_entries;\n+\tnew_field->name = avro_strdup(field_name);\n+\tnew_field->type = avro_schema_incref(field_schema);\n+        new_field->default_value = json_deep_copy((json_t *) field_default);","path":"lang/c/src/schema.c","position":54,"original_position":54,"commit_id":"d91a3bac91cfed776b87a8998a55169dc6281a31","original_commit_id":"d91a3bac91cfed776b87a8998a55169dc6281a31","user":{"login":"dcreager","id":7499,"avatar_url":"https://avatars.githubusercontent.com/u/7499?v=3","gravatar_id":"","url":"https://api.github.com/users/dcreager","html_url":"https://github.com/dcreager","followers_url":"https://api.github.com/users/dcreager/followers","following_url":"https://api.github.com/users/dcreager/following{/other_user}","gists_url":"https://api.github.com/users/dcreager/gists{/gist_id}","starred_url":"https://api.github.com/users/dcreager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcreager/subscriptions","organizations_url":"https://api.github.com/users/dcreager/orgs","repos_url":"https://api.github.com/users/dcreager/repos","events_url":"https://api.github.com/users/dcreager/events{/privacy}","received_events_url":"https://api.github.com/users/dcreager/received_events","type":"User","site_admin":false},"body":"Can you just use `json_incref` here?","created_at":"2015-04-20T16:11:25Z","updated_at":"2015-04-20T16:11:25Z","html_url":"https://github.com/dcreager/avro/pull/4#discussion_r28702993","pull_request_url":"https://api.github.com/repos/dcreager/avro/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/dcreager/avro/pulls/comments/28702993"},"html":{"href":"https://github.com/dcreager/avro/pull/4#discussion_r28702993"},"pull_request":{"href":"https://api.github.com/repos/dcreager/avro/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/dcreager/avro/pulls/4","id":33680410,"html_url":"https://github.com/dcreager/avro/pull/4","diff_url":"https://github.com/dcreager/avro/pull/4.diff","patch_url":"https://github.com/dcreager/avro/pull/4.patch","issue_url":"https://api.github.com/repos/dcreager/avro/issues/4","number":4,"state":"open","locked":false,"title":"Support default values in schema fields","user":{"login":"johnzachary","id":1051796,"avatar_url":"https://avatars.githubusercontent.com/u/1051796?v=3","gravatar_id":"","url":"https://api.github.com/users/johnzachary","html_url":"https://github.com/johnzachary","followers_url":"https://api.github.com/users/johnzachary/followers","following_url":"https://api.github.com/users/johnzachary/following{/other_user}","gists_url":"https://api.github.com/users/johnzachary/gists{/gist_id}","starred_url":"https://api.github.com/users/johnzachary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnzachary/subscriptions","organizations_url":"https://api.github.com/users/johnzachary/orgs","repos_url":"https://api.github.com/users/johnzachary/repos","events_url":"https://api.github.com/users/johnzachary/events{/privacy}","received_events_url":"https://api.github.com/users/johnzachary/received_events","type":"User","site_admin":false},"body":null,"created_at":"2015-04-20T16:08:23Z","updated_at":"2015-04-20T16:11:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"55cbeb8e256647d6ea5600b2fb921e10e92c55b8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dcreager/avro/pulls/4/commits","review_comments_url":"https://api.github.com/repos/dcreager/avro/pulls/4/comments","review_comment_url":"https://api.github.com/repos/dcreager/avro/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dcreager/avro/issues/4/comments","statuses_url":"https://api.github.com/repos/dcreager/avro/statuses/d91a3bac91cfed776b87a8998a55169dc6281a31","head":{"label":"johnzachary:default-values","ref":"default-values","sha":"d91a3bac91cfed776b87a8998a55169dc6281a31","user":{"login":"johnzachary","id":1051796,"avatar_url":"https://avatars.githubusercontent.com/u/1051796?v=3","gravatar_id":"","url":"https://api.github.com/users/johnzachary","html_url":"https://github.com/johnzachary","followers_url":"https://api.github.com/users/johnzachary/followers","following_url":"https://api.github.com/users/johnzachary/following{/other_user}","gists_url":"https://api.github.com/users/johnzachary/gists{/gist_id}","starred_url":"https://api.github.com/users/johnzachary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnzachary/subscriptions","organizations_url":"https://api.github.com/users/johnzachary/orgs","repos_url":"https://api.github.com/users/johnzachary/repos","events_url":"https://api.github.com/users/johnzachary/events{/privacy}","received_events_url":"https://api.github.com/users/johnzachary/received_events","type":"User","site_admin":false},"repo":{"id":7939479,"name":"avro","full_name":"johnzachary/avro","owner":{"login":"johnzachary","id":1051796,"avatar_url":"https://avatars.githubusercontent.com/u/1051796?v=3","gravatar_id":"","url":"https://api.github.com/users/johnzachary","html_url":"https://github.com/johnzachary","followers_url":"https://api.github.com/users/johnzachary/followers","following_url":"https://api.github.com/users/johnzachary/following{/other_user}","gists_url":"https://api.github.com/users/johnzachary/gists{/gist_id}","starred_url":"https://api.github.com/users/johnzachary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnzachary/subscriptions","organizations_url":"https://api.github.com/users/johnzachary/orgs","repos_url":"https://api.github.com/users/johnzachary/repos","events_url":"https://api.github.com/users/johnzachary/events{/privacy}","received_events_url":"https://api.github.com/users/johnzachary/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/johnzachary/avro","description":"Mirror of Apache Avro","fork":true,"url":"https://api.github.com/repos/johnzachary/avro","forks_url":"https://api.github.com/repos/johnzachary/avro/forks","keys_url":"https://api.github.com/repos/johnzachary/avro/keys{/key_id}","collaborators_url":"https://api.github.com/repos/johnzachary/avro/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/johnzachary/avro/teams","hooks_url":"https://api.github.com/repos/johnzachary/avro/hooks","issue_events_url":"https://api.github.com/repos/johnzachary/avro/issues/events{/number}","events_url":"https://api.github.com/repos/johnzachary/avro/events","assignees_url":"https://api.github.com/repos/johnzachary/avro/assignees{/user}","branches_url":"https://api.github.com/repos/johnzachary/avro/branches{/branch}","tags_url":"https://api.github.com/repos/johnzachary/avro/tags","blobs_url":"https://api.github.com/repos/johnzachary/avro/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/johnzachary/avro/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/johnzachary/avro/git/refs{/sha}","trees_url":"https://api.github.com/repos/johnzachary/avro/git/trees{/sha}","statuses_url":"https://api.github.com/repos/johnzachary/avro/statuses/{sha}","languages_url":"https://api.github.com/repos/johnzachary/avro/languages","stargazers_url":"https://api.github.com/repos/johnzachary/avro/stargazers","contributors_url":"https://api.github.com/repos/johnzachary/avro/contributors","subscribers_url":"https://api.github.com/repos/johnzachary/avro/subscribers","subscription_url":"https://api.github.com/repos/johnzachary/avro/subscription","commits_url":"https://api.github.com/repos/johnzachary/avro/commits{/sha}","git_commits_url":"https://api.github.com/repos/johnzachary/avro/git/commits{/sha}","comments_url":"https://api.github.com/repos/johnzachary/avro/comments{/number}","issue_comment_url":"https://api.github.com/repos/johnzachary/avro/issues/comments{/number}","contents_url":"https://api.github.com/repos/johnzachary/avro/contents/{+path}","compare_url":"https://api.github.com/repos/johnzachary/avro/compare/{base}...{head}","merges_url":"https://api.github.com/repos/johnzachary/avro/merges","archive_url":"https://api.github.com/repos/johnzachary/avro/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/johnzachary/avro/downloads","issues_url":"https://api.github.com/repos/johnzachary/avro/issues{/number}","pulls_url":"https://api.github.com/repos/johnzachary/avro/pulls{/number}","milestones_url":"https://api.github.com/repos/johnzachary/avro/milestones{/number}","notifications_url":"https://api.github.com/repos/johnzachary/avro/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/johnzachary/avro/labels{/name}","releases_url":"https://api.github.com/repos/johnzachary/avro/releases{/id}","created_at":"2013-01-31T15:36:46Z","updated_at":"2014-01-22T20:14:16Z","pushed_at":"2015-04-20T16:05:54Z","git_url":"git://github.com/johnzachary/avro.git","ssh_url":"git@github.com:johnzachary/avro.git","clone_url":"https://github.com/johnzachary/avro.git","svn_url":"https://github.com/johnzachary/avro","homepage":null,"size":8638,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"dcreager:redjack","ref":"redjack","sha":"506f388504fe565c931072680111a8cb6ddf6fb5","user":{"login":"dcreager","id":7499,"avatar_url":"https://avatars.githubusercontent.com/u/7499?v=3","gravatar_id":"","url":"https://api.github.com/users/dcreager","html_url":"https://github.com/dcreager","followers_url":"https://api.github.com/users/dcreager/followers","following_url":"https://api.github.com/users/dcreager/following{/other_user}","gists_url":"https://api.github.com/users/dcreager/gists{/gist_id}","starred_url":"https://api.github.com/users/dcreager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcreager/subscriptions","organizations_url":"https://api.github.com/users/dcreager/orgs","repos_url":"https://api.github.com/users/dcreager/repos","events_url":"https://api.github.com/users/dcreager/events{/privacy}","received_events_url":"https://api.github.com/users/dcreager/received_events","type":"User","site_admin":false},"repo":{"id":949871,"name":"avro","full_name":"dcreager/avro","owner":{"login":"dcreager","id":7499,"avatar_url":"https://avatars.githubusercontent.com/u/7499?v=3","gravatar_id":"","url":"https://api.github.com/users/dcreager","html_url":"https://github.com/dcreager","followers_url":"https://api.github.com/users/dcreager/followers","following_url":"https://api.github.com/users/dcreager/following{/other_user}","gists_url":"https://api.github.com/users/dcreager/gists{/gist_id}","starred_url":"https://api.github.com/users/dcreager/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcreager/subscriptions","organizations_url":"https://api.github.com/users/dcreager/orgs","repos_url":"https://api.github.com/users/dcreager/repos","events_url":"https://api.github.com/users/dcreager/events{/privacy}","received_events_url":"https://api.github.com/users/dcreager/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dcreager/avro","description":"Mirror of Apache Avro","fork":true,"url":"https://api.github.com/repos/dcreager/avro","forks_url":"https://api.github.com/repos/dcreager/avro/forks","keys_url":"https://api.github.com/repos/dcreager/avro/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcreager/avro/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcreager/avro/teams","hooks_url":"https://api.github.com/repos/dcreager/avro/hooks","issue_events_url":"https://api.github.com/repos/dcreager/avro/issues/events{/number}","events_url":"https://api.github.com/repos/dcreager/avro/events","assignees_url":"https://api.github.com/repos/dcreager/avro/assignees{/user}","branches_url":"https://api.github.com/repos/dcreager/avro/branches{/branch}","tags_url":"https://api.github.com/repos/dcreager/avro/tags","blobs_url":"https://api.github.com/repos/dcreager/avro/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcreager/avro/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcreager/avro/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcreager/avro/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcreager/avro/statuses/{sha}","languages_url":"https://api.github.com/repos/dcreager/avro/languages","stargazers_url":"https://api.github.com/repos/dcreager/avro/stargazers","contributors_url":"https://api.github.com/repos/dcreager/avro/contributors","subscribers_url":"https://api.github.com/repos/dcreager/avro/subscribers","subscription_url":"https://api.github.com/repos/dcreager/avro/subscription","commits_url":"https://api.github.com/repos/dcreager/avro/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcreager/avro/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcreager/avro/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcreager/avro/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcreager/avro/contents/{+path}","compare_url":"https://api.github.com/repos/dcreager/avro/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcreager/avro/merges","archive_url":"https://api.github.com/repos/dcreager/avro/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcreager/avro/downloads","issues_url":"https://api.github.com/repos/dcreager/avro/issues{/number}","pulls_url":"https://api.github.com/repos/dcreager/avro/pulls{/number}","milestones_url":"https://api.github.com/repos/dcreager/avro/milestones{/number}","notifications_url":"https://api.github.com/repos/dcreager/avro/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcreager/avro/labels{/name}","releases_url":"https://api.github.com/repos/dcreager/avro/releases{/id}","created_at":"2010-09-30T00:09:35Z","updated_at":"2014-01-27T17:37:28Z","pushed_at":"2015-04-20T16:08:23Z","git_url":"git://github.com/dcreager/avro.git","ssh_url":"git@github.com:dcreager/avro.git","clone_url":"https://github.com/dcreager/avro.git","svn_url":"https://github.com/dcreager/avro","homepage":null,"size":8677,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":1,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/dcreager/avro/pulls/4"},"html":{"href":"https://github.com/dcreager/avro/pull/4"},"issue":{"href":"https://api.github.com/repos/dcreager/avro/issues/4"},"comments":{"href":"https://api.github.com/repos/dcreager/avro/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/dcreager/avro/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/dcreager/avro/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dcreager/avro/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/dcreager/avro/statuses/d91a3bac91cfed776b87a8998a55169dc6281a31"}}}}