{"action":"opened","number":1058,"pull_request":{"url":"https://api.github.com/repos/gocql/gocql/pulls/1058","id":167141941,"html_url":"https://github.com/gocql/gocql/pull/1058","diff_url":"https://github.com/gocql/gocql/pull/1058.diff","patch_url":"https://github.com/gocql/gocql/pull/1058.patch","issue_url":"https://api.github.com/repos/gocql/gocql/issues/1058","number":1058,"state":"open","locked":false,"title":"marshal: fix marshalling of ints with a wrong type","user":{"login":"vrischmann","id":1916079,"avatar_url":"https://avatars0.githubusercontent.com/u/1916079?v=4","gravatar_id":"","url":"https://api.github.com/users/vrischmann","html_url":"https://github.com/vrischmann","followers_url":"https://api.github.com/users/vrischmann/followers","following_url":"https://api.github.com/users/vrischmann/following{/other_user}","gists_url":"https://api.github.com/users/vrischmann/gists{/gist_id}","starred_url":"https://api.github.com/users/vrischmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrischmann/subscriptions","organizations_url":"https://api.github.com/users/vrischmann/orgs","repos_url":"https://api.github.com/users/vrischmann/repos","events_url":"https://api.github.com/users/vrischmann/events{/privacy}","received_events_url":"https://api.github.com/users/vrischmann/received_events","type":"User","site_admin":false},"body":"When trying to marshal a value with the wrong type into a int, smallint or tinyint, marshalInt, marshalSmallint and marshalTinyint fail with a panic because IsNil is called on a non-pointer value.\r\n\r\nTest program:\r\n\r\n    package main\r\n    import (\r\n            \"log\"\r\n            \"github.com/gocql/gocql\"\r\n    )\r\n    func main() {\r\n            cfg := gocql.NewCluster(\"localhost:9042\")\r\n            session, err := cfg.CreateSession()\r\n            if err != nil {\r\n                    log.Fatal(err)\r\n            }\r\n            const (\r\n                    tableDDL = `CREATE TABLE test.foobar (id text PRIMARY KEY, val int, val2 tinyint, val3 smallint)`\r\n            )\r\n            if err := session.Query(tableDDL).Exec(); err != nil {\r\n                    log.Printf(\"unable to create table: %v\", err)\r\n            }\r\n            err = session.Query(\"UPDATE test.foobar SET val = ? WHERE id = ?\", float64(456), \"foobar\").Exec()\r\n            if err != nil {\r\n                    log.Print(err)\r\n            }\r\n            err = session.Query(\"UPDATE test.foobar SET val2 = ? WHERE id = ?\", float64(456), \"foobar\").Exec()\r\n            if err != nil {\r\n                    log.Print(err)\r\n            }\r\n            err = session.Query(\"UPDATE test.foobar SET val3 = ? WHERE id = ?\", float64(456), \"foobar\").Exec()\r\n            if err != nil {\r\n                    log.Print(err)\r\n            }\r\n    }\r\n\r\nAnd here's the panic I get:\r\n\r\n    panic: reflect: call of reflect.Value.IsNil on float64 Value\r\n    goroutine 1 [running]:\r\n    reflect.Value.IsNil(0x6470e0, 0x6cbce0, 0x8e, 0x7c5040)\r\n            /usr/local/go/src/reflect/value.go:1001 +0x12e\r\n    github.com/gocql/gocql.marshalSmallInt(0x7c14e0, 0xc42019e1e0, 0x6470e0, 0x6cbce0, 0x0, 0x0, 0x672dc0, 0x10, 0xe0000000010)\r\n            /home/vincent/dev/go/src/github.com/gocql/gocql/marshal.go:334 +0x2ed\r\n    github.com/gocql/gocql.Marshal(0x7c14e0, 0xc42019e1e0, 0x6470e0, 0x6cbce0, 0xc4200a9ad0, 0x441cc7, 0x60, 0x672dc0, 0xc4201e6001)\r\n            /home/vincent/dev/go/src/github.com/gocql/gocql/marshal.go:73 +0xd4a\r\n    github.com/gocql/gocql.marshalQueryValue(0x7c14e0, 0xc42019e1e0, 0x6470e0, 0x6cbce0, 0xc4200fc6c0, 0x2, 0x0)\r\n            /home/vincent/dev/go/src/github.com/gocql/gocql/conn.go:760 +0xc6\r\n    github.com/gocql/gocql.(*Conn).executeQuery(0xc4201901c0, 0xc4201a4480, 0xb7c3396)\r\n            /home/vincent/dev/go/src/github.com/gocql/gocql/conn.go:829 +0x3e1\r\n    github.com/gocql/gocql.(*Query).execute(0xc4201a4480, 0xc4201901c0, 0x7db860)\r\n            /home/vincent/dev/go/src/github.com/gocql/gocql/session.go:773 +0x35\r\n    github.com/gocql/gocql.(*queryExecutor).attemptQuery(0xc42000cf00, 0x7c2a80, 0xc4201a4480, 0xc4201901c0, 0x7fdbb28256c8)\r\n            /home/vincent/dev/go/src/github.com/gocql/gocql/query_executor.go:23 +0x6a\r\n    github.com/gocql/gocql.(*queryExecutor).executeQuery(0xc42000cf00, 0x7c2a80, 0xc4201a4480, 0xc4200a9e88, 0x61237f, 0x6a7a1b)\r\n            /home/vincent/dev/go/src/github.com/gocql/gocql/query_executor.go:52 +0x189\r\n    github.com/gocql/gocql.(*Session).executeQuery(0xc4200f8000, 0xc4201a4480, 0xc4200a9e00)\r\n            /home/vincent/dev/go/src/github.com/gocql/gocql/session.go:398 +0xc1\r\n    github.com/gocql/gocql.(*Query).Iter(0xc4201a4480, 0xc4201a4480)\r\n            /home/vincent/dev/go/src/github.com/gocql/gocql/session.go:965 +0xbf\r\n    github.com/gocql/gocql.(*Query).Exec(0xc4201a4480, 0x6a7a1b, 0x2c)\r\n            /home/vincent/dev/go/src/github.com/gocql/gocql/session.go:948 +0x2b\r\n    main.main()\r\n            /home/vincent/tmp/gocql-marshal-bug/main.go:26 +0x250\r\n    exit status 2\r\n\r\nAfter applying the fix:\r\n\r\n    2018/02/05 14:17:00 can not marshal float64 into int\r\n    2018/02/05 14:17:00 can not marshal float64 into tinyint\r\n    2018/02/05 14:17:00 can not marshal float64 into smallint\r\n","created_at":"2018-02-05T13:19:33Z","updated_at":"2018-02-05T13:19:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/gocql/gocql/pulls/1058/commits","review_comments_url":"https://api.github.com/repos/gocql/gocql/pulls/1058/comments","review_comment_url":"https://api.github.com/repos/gocql/gocql/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gocql/gocql/issues/1058/comments","statuses_url":"https://api.github.com/repos/gocql/gocql/statuses/0bea459d50428313d0707c40978b2caa84acd858","head":{"label":"vrischmann:fix-marshal-ints","ref":"fix-marshal-ints","sha":"0bea459d50428313d0707c40978b2caa84acd858","user":{"login":"vrischmann","id":1916079,"avatar_url":"https://avatars0.githubusercontent.com/u/1916079?v=4","gravatar_id":"","url":"https://api.github.com/users/vrischmann","html_url":"https://github.com/vrischmann","followers_url":"https://api.github.com/users/vrischmann/followers","following_url":"https://api.github.com/users/vrischmann/following{/other_user}","gists_url":"https://api.github.com/users/vrischmann/gists{/gist_id}","starred_url":"https://api.github.com/users/vrischmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrischmann/subscriptions","organizations_url":"https://api.github.com/users/vrischmann/orgs","repos_url":"https://api.github.com/users/vrischmann/repos","events_url":"https://api.github.com/users/vrischmann/events{/privacy}","received_events_url":"https://api.github.com/users/vrischmann/received_events","type":"User","site_admin":false},"repo":{"id":25073976,"name":"gocql","full_name":"vrischmann/gocql","owner":{"login":"vrischmann","id":1916079,"avatar_url":"https://avatars0.githubusercontent.com/u/1916079?v=4","gravatar_id":"","url":"https://api.github.com/users/vrischmann","html_url":"https://github.com/vrischmann","followers_url":"https://api.github.com/users/vrischmann/followers","following_url":"https://api.github.com/users/vrischmann/following{/other_user}","gists_url":"https://api.github.com/users/vrischmann/gists{/gist_id}","starred_url":"https://api.github.com/users/vrischmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrischmann/subscriptions","organizations_url":"https://api.github.com/users/vrischmann/orgs","repos_url":"https://api.github.com/users/vrischmann/repos","events_url":"https://api.github.com/users/vrischmann/events{/privacy}","received_events_url":"https://api.github.com/users/vrischmann/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vrischmann/gocql","description":"Package gocql implements a fast and robust Cassandra client for the Go programming language.","fork":true,"url":"https://api.github.com/repos/vrischmann/gocql","forks_url":"https://api.github.com/repos/vrischmann/gocql/forks","keys_url":"https://api.github.com/repos/vrischmann/gocql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vrischmann/gocql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vrischmann/gocql/teams","hooks_url":"https://api.github.com/repos/vrischmann/gocql/hooks","issue_events_url":"https://api.github.com/repos/vrischmann/gocql/issues/events{/number}","events_url":"https://api.github.com/repos/vrischmann/gocql/events","assignees_url":"https://api.github.com/repos/vrischmann/gocql/assignees{/user}","branches_url":"https://api.github.com/repos/vrischmann/gocql/branches{/branch}","tags_url":"https://api.github.com/repos/vrischmann/gocql/tags","blobs_url":"https://api.github.com/repos/vrischmann/gocql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vrischmann/gocql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vrischmann/gocql/git/refs{/sha}","trees_url":"https://api.github.com/repos/vrischmann/gocql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vrischmann/gocql/statuses/{sha}","languages_url":"https://api.github.com/repos/vrischmann/gocql/languages","stargazers_url":"https://api.github.com/repos/vrischmann/gocql/stargazers","contributors_url":"https://api.github.com/repos/vrischmann/gocql/contributors","subscribers_url":"https://api.github.com/repos/vrischmann/gocql/subscribers","subscription_url":"https://api.github.com/repos/vrischmann/gocql/subscription","commits_url":"https://api.github.com/repos/vrischmann/gocql/commits{/sha}","git_commits_url":"https://api.github.com/repos/vrischmann/gocql/git/commits{/sha}","comments_url":"https://api.github.com/repos/vrischmann/gocql/comments{/number}","issue_comment_url":"https://api.github.com/repos/vrischmann/gocql/issues/comments{/number}","contents_url":"https://api.github.com/repos/vrischmann/gocql/contents/{+path}","compare_url":"https://api.github.com/repos/vrischmann/gocql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vrischmann/gocql/merges","archive_url":"https://api.github.com/repos/vrischmann/gocql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vrischmann/gocql/downloads","issues_url":"https://api.github.com/repos/vrischmann/gocql/issues{/number}","pulls_url":"https://api.github.com/repos/vrischmann/gocql/pulls{/number}","milestones_url":"https://api.github.com/repos/vrischmann/gocql/milestones{/number}","notifications_url":"https://api.github.com/repos/vrischmann/gocql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vrischmann/gocql/labels{/name}","releases_url":"https://api.github.com/repos/vrischmann/gocql/releases{/id}","deployments_url":"https://api.github.com/repos/vrischmann/gocql/deployments","created_at":"2014-10-11T10:33:23Z","updated_at":"2016-10-29T13:53:36Z","pushed_at":"2018-02-05T13:11:16Z","git_url":"git://github.com/vrischmann/gocql.git","ssh_url":"git@github.com:vrischmann/gocql.git","clone_url":"https://github.com/vrischmann/gocql.git","svn_url":"https://github.com/vrischmann/gocql","homepage":"http://gocql.github.io/","size":2451,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause"},"forks":0,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"gocql:master","ref":"master","sha":"dd47639f787e8583e1a13e17e20a9f6c4332bc29","user":{"login":"gocql","id":6570216,"avatar_url":"https://avatars1.githubusercontent.com/u/6570216?v=4","gravatar_id":"","url":"https://api.github.com/users/gocql","html_url":"https://github.com/gocql","followers_url":"https://api.github.com/users/gocql/followers","following_url":"https://api.github.com/users/gocql/following{/other_user}","gists_url":"https://api.github.com/users/gocql/gists{/gist_id}","starred_url":"https://api.github.com/users/gocql/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gocql/subscriptions","organizations_url":"https://api.github.com/users/gocql/orgs","repos_url":"https://api.github.com/users/gocql/repos","events_url":"https://api.github.com/users/gocql/events{/privacy}","received_events_url":"https://api.github.com/users/gocql/received_events","type":"Organization","site_admin":false},"repo":{"id":5561238,"name":"gocql","full_name":"gocql/gocql","owner":{"login":"gocql","id":6570216,"avatar_url":"https://avatars1.githubusercontent.com/u/6570216?v=4","gravatar_id":"","url":"https://api.github.com/users/gocql","html_url":"https://github.com/gocql","followers_url":"https://api.github.com/users/gocql/followers","following_url":"https://api.github.com/users/gocql/following{/other_user}","gists_url":"https://api.github.com/users/gocql/gists{/gist_id}","starred_url":"https://api.github.com/users/gocql/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gocql/subscriptions","organizations_url":"https://api.github.com/users/gocql/orgs","repos_url":"https://api.github.com/users/gocql/repos","events_url":"https://api.github.com/users/gocql/events{/privacy}","received_events_url":"https://api.github.com/users/gocql/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gocql/gocql","description":"Package gocql implements a fast and robust Cassandra client for the Go programming language.","fork":false,"url":"https://api.github.com/repos/gocql/gocql","forks_url":"https://api.github.com/repos/gocql/gocql/forks","keys_url":"https://api.github.com/repos/gocql/gocql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gocql/gocql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gocql/gocql/teams","hooks_url":"https://api.github.com/repos/gocql/gocql/hooks","issue_events_url":"https://api.github.com/repos/gocql/gocql/issues/events{/number}","events_url":"https://api.github.com/repos/gocql/gocql/events","assignees_url":"https://api.github.com/repos/gocql/gocql/assignees{/user}","branches_url":"https://api.github.com/repos/gocql/gocql/branches{/branch}","tags_url":"https://api.github.com/repos/gocql/gocql/tags","blobs_url":"https://api.github.com/repos/gocql/gocql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gocql/gocql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gocql/gocql/git/refs{/sha}","trees_url":"https://api.github.com/repos/gocql/gocql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gocql/gocql/statuses/{sha}","languages_url":"https://api.github.com/repos/gocql/gocql/languages","stargazers_url":"https://api.github.com/repos/gocql/gocql/stargazers","contributors_url":"https://api.github.com/repos/gocql/gocql/contributors","subscribers_url":"https://api.github.com/repos/gocql/gocql/subscribers","subscription_url":"https://api.github.com/repos/gocql/gocql/subscription","commits_url":"https://api.github.com/repos/gocql/gocql/commits{/sha}","git_commits_url":"https://api.github.com/repos/gocql/gocql/git/commits{/sha}","comments_url":"https://api.github.com/repos/gocql/gocql/comments{/number}","issue_comment_url":"https://api.github.com/repos/gocql/gocql/issues/comments{/number}","contents_url":"https://api.github.com/repos/gocql/gocql/contents/{+path}","compare_url":"https://api.github.com/repos/gocql/gocql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gocql/gocql/merges","archive_url":"https://api.github.com/repos/gocql/gocql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gocql/gocql/downloads","issues_url":"https://api.github.com/repos/gocql/gocql/issues{/number}","pulls_url":"https://api.github.com/repos/gocql/gocql/pulls{/number}","milestones_url":"https://api.github.com/repos/gocql/gocql/milestones{/number}","notifications_url":"https://api.github.com/repos/gocql/gocql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gocql/gocql/labels{/name}","releases_url":"https://api.github.com/repos/gocql/gocql/releases{/id}","deployments_url":"https://api.github.com/repos/gocql/gocql/deployments","created_at":"2012-08-26T15:42:42Z","updated_at":"2018-02-05T07:36:50Z","pushed_at":"2018-01-23T13:03:48Z","git_url":"git://github.com/gocql/gocql.git","ssh_url":"git@github.com:gocql/gocql.git","clone_url":"https://github.com/gocql/gocql.git","svn_url":"https://github.com/gocql/gocql","homepage":"http://gocql.github.io/","size":2500,"stargazers_count":1196,"watchers_count":1196,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":333,"mirror_url":null,"archived":false,"open_issues_count":68,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause"},"forks":333,"open_issues":68,"watchers":1196,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gocql/gocql/pulls/1058"},"html":{"href":"https://github.com/gocql/gocql/pull/1058"},"issue":{"href":"https://api.github.com/repos/gocql/gocql/issues/1058"},"comments":{"href":"https://api.github.com/repos/gocql/gocql/issues/1058/comments"},"review_comments":{"href":"https://api.github.com/repos/gocql/gocql/pulls/1058/comments"},"review_comment":{"href":"https://api.github.com/repos/gocql/gocql/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gocql/gocql/pulls/1058/commits"},"statuses":{"href":"https://api.github.com/repos/gocql/gocql/statuses/0bea459d50428313d0707c40978b2caa84acd858"}},"author_association":"CONTRIBUTOR","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":3,"deletions":3,"changed_files":1}}
{"actor":{"display_login":"vrischmann"}}