{"action":"closed","issue":{"url":"https://api.github.com/repos/Flexget/Flexget/issues/979","repository_url":"https://api.github.com/repos/Flexget/Flexget","labels_url":"https://api.github.com/repos/Flexget/Flexget/issues/979/labels{/name}","comments_url":"https://api.github.com/repos/Flexget/Flexget/issues/979/comments","events_url":"https://api.github.com/repos/Flexget/Flexget/issues/979/events","html_url":"https://github.com/Flexget/Flexget/issues/979","id":143834228,"number":979,"title":"BUG: Unhandled error in plugin series: (sqlite3.OperationalError) ambiguous column name: first_seen","user":{"login":"gsstark","id":484000,"avatar_url":"https://avatars.githubusercontent.com/u/484000?v=3","gravatar_id":"","url":"https://api.github.com/users/gsstark","html_url":"https://github.com/gsstark","followers_url":"https://api.github.com/users/gsstark/followers","following_url":"https://api.github.com/users/gsstark/following{/other_user}","gists_url":"https://api.github.com/users/gsstark/gists{/gist_id}","starred_url":"https://api.github.com/users/gsstark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsstark/subscriptions","organizations_url":"https://api.github.com/users/gsstark/orgs","repos_url":"https://api.github.com/users/gsstark/repos","events_url":"https://api.github.com/users/gsstark/events{/privacy}","received_events_url":"https://api.github.com/users/gsstark/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-27T18:15:32Z","updated_at":"2016-03-28T17:57:55Z","closed_at":"2016-03-28T17:57:55Z","body":"`2016-03-27 19:09 CRITICAL task          torrent-day     BUG: Unhandled error in plugin series: (sqlite3.OperationalError) ambiguous column name: first_seen [SQL: u'SELECT series_episodes.id AS series_episodes_id, series_episodes.identifier AS series_episodes_identifier, series_episodes.season AS series_episodes_season, series_episodes.number AS series_episodes_number, series_episodes.identified_by AS series_episodes_identified_by, series_episodes.series_id AS series_episodes_series_id \\nFROM series_episodes JOIN episode_releases ON series_episodes.id = episode_releases.episode_id JOIN series ON series.id = series_episodes.series_id \\nWHERE series.id = ? AND episode_releases.downloaded = 1 ORDER BY first_seen DESC\\n LIMIT ? OFFSET ?'] [parameters: (87, 1, 0)]`\r\n\r\nAnd indeed... both these tables listed in the query above have a \"first_seen\" column in them:\r\n\r\n```\r\nsqlite> .schema series_episodes\r\nCREATE TABLE series_episodes (\r\n        id INTEGER NOT NULL, \r\n        identifier VARCHAR, \r\n        first_seen DATETIME, \r\n        season INTEGER, \r\n        number INTEGER, \r\n        series_id INTEGER NOT NULL, identified_by VARCHAR, \r\n        PRIMARY KEY (id), \r\n        FOREIGN KEY(series_id) REFERENCES series (id)\r\n);\r\nsqlite> .schema episode_releases\r\nCREATE TABLE episode_releases (\r\n        id INTEGER NOT NULL, \r\n        episode_id INTEGER NOT NULL, \r\n        quality VARCHAR, \r\n        downloaded BOOLEAN, \r\n        proper_count INTEGER, \r\n        title VARCHAR, first_seen DATETIME, \r\n        PRIMARY KEY (id), \r\n        FOREIGN KEY(episode_id) REFERENCES series_episodes (id), \r\n        CHECK (downloaded IN (0, 1))\r\n);\r\n```\r\n\r\nSo the ORDER BY is ambiguous (though technically in SQL only columns listed in the target list are valid in the ORDER BY list but I guess sqlite is liberal about this).\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python2.7/dist-packages/flexget/task.py\", line 435, in __run_plugin\r\n    return method(*args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/flexget/event.py\", line 22, in __call__\r\n    return self.func(*args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/flexget/plugins/filter/series.py\", line 1041, in on_task_filter\r\n    self.process_series(task, series_entries, series_config)\r\n  File \"/usr/local/lib/python2.7/dist-packages/flexget/plugins/filter/series.py\", line 1203, in process_series\r\n    if self.process_episode_tracking(ep, entries, grace=len(series_entries) + 2, backfill=backfill):\r\n  File \"/usr/local/lib/python2.7/dist-packages/flexget/plugins/filter/series.py\", line 1329, in process_episode_tracking\r\n    latest = get_latest_release(episode.series)\r\n  File \"/usr/local/lib/python2.7/dist-packages/flexget/plugins/filter/series.py\", line 503, in get_latest_release\r\n    latest_release = releases.order_by(desc(Episode.first_seen)).first()\r\n  File \"/usr/lib/python2.7/dist-packages/sqlalchemy/orm/query.py\", line 2634, in first\r\n    ret = list(self[0:1])\r\n  File \"/usr/lib/python2.7/dist-packages/sqlalchemy/orm/query.py\", line 2457, in __getitem__\r\n    return list(res)\r\n  File \"/usr/lib/python2.7/dist-packages/sqlalchemy/orm/query.py\", line 2736, in __iter__\r\n    return self._execute_and_instances(context)\r\n  File \"/usr/lib/python2.7/dist-packages/sqlalchemy/orm/query.py\", line 2751, in _execute_and_instances\r\n    result = conn.execute(querycontext.statement, self._params)\r\n  File \"/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py\", line 914, in execute\r\n    return meth(self, multiparams, params)\r\n  File \"/usr/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py\", line 323, in _execute_on_connection\r\n    return connection._execute_clauseelement(self, multiparams, params)\r\n  File \"/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py\", line 1010, in _execute_clauseelement\r\n    compiled_sql, distilled_params\r\n  File \"/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py\", line 1146, in _execute_context\r\n    context)\r\n```"}}