{"action":"created","issue":{"url":"https://api.github.com/repos/mymarilyn/clickhouse-driver/issues/67","repository_url":"https://api.github.com/repos/mymarilyn/clickhouse-driver","labels_url":"https://api.github.com/repos/mymarilyn/clickhouse-driver/issues/67/labels{/name}","comments_url":"https://api.github.com/repos/mymarilyn/clickhouse-driver/issues/67/comments","events_url":"https://api.github.com/repos/mymarilyn/clickhouse-driver/issues/67/events","html_url":"https://github.com/mymarilyn/clickhouse-driver/pull/67","id":395495433,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQxOTM0Mjgw","number":67,"title":"Enum option parsing is not handling all supported character correctly","user":{"login":"sochi","id":2857409,"node_id":"MDQ6VXNlcjI4NTc0MDk=","avatar_url":"https://avatars2.githubusercontent.com/u/2857409?v=4","gravatar_id":"","url":"https://api.github.com/users/sochi","html_url":"https://github.com/sochi","followers_url":"https://api.github.com/users/sochi/followers","following_url":"https://api.github.com/users/sochi/following{/other_user}","gists_url":"https://api.github.com/users/sochi/gists{/gist_id}","starred_url":"https://api.github.com/users/sochi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sochi/subscriptions","organizations_url":"https://api.github.com/users/sochi/orgs","repos_url":"https://api.github.com/users/sochi/repos","events_url":"https://api.github.com/users/sochi/events{/privacy}","received_events_url":"https://api.github.com/users/sochi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2019-01-03T08:51:04Z","updated_at":"2019-01-03T12:04:50Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/mymarilyn/clickhouse-driver/pulls/67","html_url":"https://github.com/mymarilyn/clickhouse-driver/pull/67","diff_url":"https://github.com/mymarilyn/clickhouse-driver/pull/67.diff","patch_url":"https://github.com/mymarilyn/clickhouse-driver/pull/67.patch"},"body":"When querying a table with `Enum` options containing comma and a space, the parsing of the options fails (see below).\r\n\r\nWith an example table as\r\n```\r\nCREATE TABLE default.test_table (\r\n\tid UInt64,  \r\n\tdatetime DateTime,  \r\n\taction_type Enum8('first' = 1, 'test_rename = 3, ' = 2, 'dele\\'te' = 3, 'to\"uch' = 4)\r\n) ENGINE = MergeTree\r\n```\r\nthe options are a bit non-standard but seem to be actually permitted. (Kind of created these options by accident due to a typo in a query and then figured out that the parsing could be improved on this.)\r\n\r\nAnd while testing the the original parsing, I've also noticed that it is not really handling any empty characters before the first option; it gets prepended into the first option, e.g., `Enum8(  'one' = 1, 'exa\"mple' = 2, 'three' = 3)` is turned into `{\"  'one\": 1, 'exa\"mple': 2, 'three': 3}` which doesn't seem right either.\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/home/.../test_clickhouse_integration.py\", line 92, in <module>\r\n    .limit(5)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/sqlalchemy/orm/query.py\", line 2843, in all\r\n    return list(self)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/sqlalchemy/orm/query.py\", line 2995, in __iter__\r\n    return self._execute_and_instances(context)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/sqlalchemy/orm/query.py\", line 3018, in _execute_and_instances\r\n    result = conn.execute(querycontext.statement, self._params)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py\", line 948, in execute\r\n    return meth(self, multiparams, params)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/sqlalchemy/sql/elements.py\", line 269, in _execute_on_connection\r\n    return connection._execute_clauseelement(self, multiparams, params)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py\", line 1060, in _execute_clauseelement\r\n    compiled_sql, distilled_params\r\n  File \"/home/.../venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py\", line 1200, in _execute_context\r\n    context)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py\", line 1416, in _handle_dbapi_exception\r\n    util.reraise(*exc_info)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/sqlalchemy/util/compat.py\", line 249, in reraise\r\n    raise value\r\n  File \"/home/.../venv/lib/python3.6/site-packages/sqlalchemy/engine/base.py\", line 1193, in _execute_context\r\n    context)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_sqlalchemy/drivers/base.py\", line 492, in do_execute\r\n    cursor.execute(statement, parameters, context=context)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_sqlalchemy/drivers/native/connector.py\", line 125, in execute\r\n    external_tables=external_tables, settings=settings\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/client.py\", line 119, in execute\r\n    columnar=columnar\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/client.py\", line 192, in process_ordinary_query\r\n    columnar=columnar)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/client.py\", line 42, in receive_result\r\n    return result.get_result()\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/result.py\", line 39, in get_result\r\n    for packet in self.packet_generator:\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/client.py\", line 54, in packet_generator\r\n    packet = self.receive_packet()\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/client.py\", line 68, in receive_packet\r\n    packet = self.connection.receive_packet()\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/connection.py\", line 334, in receive_packet\r\n    packet.block = self.receive_data()\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/connection.py\", line 393, in receive_data\r\n    block = self.block_in.read()\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/streams/native.py\", line 80, in read\r\n    self.fin)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/columns/service.py\", line 67, in read_column\r\n    column = get_column_by_spec(column_spec, column_options=column_options)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/columns/service.py\", line 45, in get_column_by_spec\r\n    return create_enum_column(spec, column_options)\r\n  File \"/home/.../venv/lib/python3.6/site-packages/clickhouse_driver/columns/enumcolumn.py\", line 65, in create_enum_column\r\n    value = int(param[pos + 1:].lstrip(' ='))\r\nValueError: invalid literal for int() with base 10: 'test_rename = 3'\r\n```\r\n\r\nDo you agree that it make sense to fix the options parsing? Should I add some tests for it?\r\n\r\nIn addition I've added escaping of single quotes into generated error message."},"comment":{"url":"https://api.github.com/repos/mymarilyn/clickhouse-driver/issues/comments/451125092","html_url":"https://github.com/mymarilyn/clickhouse-driver/pull/67#issuecomment-451125092","issue_url":"https://api.github.com/repos/mymarilyn/clickhouse-driver/issues/67","id":451125092,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MTEyNTA5Mg==","user":{"login":"coveralls","id":2354108,"node_id":"MDQ6VXNlcjIzNTQxMDg=","avatar_url":"https://avatars1.githubusercontent.com/u/2354108?v=4","gravatar_id":"","url":"https://api.github.com/users/coveralls","html_url":"https://github.com/coveralls","followers_url":"https://api.github.com/users/coveralls/followers","following_url":"https://api.github.com/users/coveralls/following{/other_user}","gists_url":"https://api.github.com/users/coveralls/gists{/gist_id}","starred_url":"https://api.github.com/users/coveralls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveralls/subscriptions","organizations_url":"https://api.github.com/users/coveralls/orgs","repos_url":"https://api.github.com/users/coveralls/repos","events_url":"https://api.github.com/users/coveralls/events{/privacy}","received_events_url":"https://api.github.com/users/coveralls/received_events","type":"User","site_admin":false},"created_at":"2019-01-03T12:04:50Z","updated_at":"2019-01-03T12:04:50Z","author_association":"NONE","body":"\n[![Coverage Status](https://coveralls.io/builds/20884012/badge)](https://coveralls.io/builds/20884012)\n\nCoverage decreased (-2.6%) to 93.158% when pulling **15c3f1e101c5ab15e3dce3307bf8dacdcda4b198 on sochi:master** into **9efd220f871e44aaa3f29e94c289a42725eba175 on mymarilyn:master**.\n"}}
{"actor":{"display_login":"coveralls"}}